[jsinterp] `interpret_statement`: Match `attribute` before `indexing`

Authored by: bashonly
pull/12760/head
bashonly 4 months ago
parent 32893787fc
commit a4392af113
No known key found for this signature in database
GPG Key ID: 783F096F253D15B0

@ -443,6 +443,9 @@ class TestJSInterpreter(unittest.TestCase):
self._test('function f(){return "012345678".slice(-1, 1)}', '')
self._test('function f(){return "012345678".slice(-3, -1)}', '67')
def test_splice(self):
self._test('function f(){var T = ["0", "1", "2"]; T["splice"](2, 1, "0")[0]; return T }', ['0', '1', '0'])
def test_js_number_to_string(self):
for test, radix, expected in [
(0, None, '0'),

@ -611,10 +611,16 @@ class JSInterpreter:
=(?!=)(?P<expr>.*)$
)|(?P<return>
(?!if|return|true|false|null|undefined|NaN)(?P<name>{_NAME_RE})$
)|(?P<attribute>
(?P<var>{_NAME_RE})(?:
(?P<nullish>\?)?\.(?P<member>[^(]+)|
\[(?P<member2>[^[\]]+
(?:\[[^[\]]+
(?:\[[^\]]+\])?\]
)?)
\])\s*
)|(?P<indexing>
(?P<in>{_NAME_RE})\[(?P<idx>.+)\]$
)|(?P<attribute>
(?P<var>{_NAME_RE})(?:(?P<nullish>\?)?\.(?P<member>[^(]+)|\[(?P<member2>[^\[\]]+(?:\[[^\[\]]+(?:\[[^\]]+\])?\])?)\])\s*
)|(?P<function>
(?P<fname>{_NAME_RE})\((?P<args>.*)\)$
)''', expr)

Loading…
Cancel
Save