-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
In evaljs, trailing commas are allowed in array declarations, but when using Array constructors, it causes a crash:
import dukpy
testArray1 = '''
var array1 = [1, 2, 3, ];
array1.reduce(function(a, b) { return a + b; }, 0);
'''
print(dukpy.evaljs(testArray1))
testArray2 = '''
var array2 = new Array(1, 2, 3, );
array2.reduce(function(a, b) { return a + b; }, 0);
'''
print(dukpy.evaljs(testArray2))
~ $ python3 test.py
6
Traceback (most recent call last):
File "test.py", line 12, in <module>
print(dukpy.evaljs(testArray2))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dukpy/evaljs.py", line 134, in evaljs
return JSInterpreter().evaljs(code, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dukpy/evaljs.py", line 57, in evaljs
res = _dukpy.eval_string(self, jscode, jsvars)
_dukpy.JSRuntimeError: SyntaxError: empty expression not allowed (line 2)
src/pyduktape.c:2
duk_js_compiler.c:4731
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels