[jsinterp] Improve nested attribute support

pull/12760/head
sepro 4 months ago committed by bashonly
parent 6eaa574c82
commit 06d2008491
No known key found for this signature in database
GPG Key ID: 783F096F253D15B0

@ -403,6 +403,8 @@ class TestJSInterpreter(unittest.TestCase):
test_result = list('test')
tests = [
'function f(a, b){return a.split(b)}',
'function f(a, b){return a["split"](b)}',
'function f(a, b){let x = ["split"]; return a[x[0]](b)}',
'function f(a, b){return String.prototype.split.call(a, b)}',
'function f(a, b){return String.prototype.split.apply(a, [b])}',
]

@ -614,7 +614,7 @@ class JSInterpreter:
)|(?P<indexing>
(?P<in>{_NAME_RE})\[(?P<idx>.+)\]$
)|(?P<attribute>
(?P<var>{_NAME_RE})(?:(?P<nullish>\?)?\.(?P<member>[^(]+)|\[(?P<member2>[^\]]+)\])\s*
(?P<var>{_NAME_RE})(?:(?P<nullish>\?)?\.(?P<member>[^(]+)|\[(?P<member2>[^\[\]]+(?:\[[^\[\]]+(?:\[[^\]]+\])?\])?)\])\s*
)|(?P<function>
(?P<fname>{_NAME_RE})\((?P<args>.*)\)$
)''', expr)

Loading…
Cancel
Save