svaarala / duktape

Duktape - embeddable Javascript engine with a focus on portability and compact footprint
MIT License
5.92k stars 514 forks source link

Cannot parse complex functions #2507

Open ghost opened 1 year ago

ghost commented 1 year ago
((o) Duktape 2.7.0 (03d4d72-dirty)
duk> function x() { for (i=0; i-10; i++) { try { if (i == 5) throw i} catch {return 10} finally {break} }; return 42 }; x()
SyntaxError: parse error (line 1)
    at [anon] (input:1) internal
    at [anon] (duk_js_compiler.c:511) internal
duk> function x() { var a; return a?.qq; }; x();
SyntaxError: parse error (line 1)
    at [anon] (input:1) internal
    at [anon] (duk_js_compiler.c:3797) internal
duk> function f(){return 0 ?? 42;}; f();
SyntaxError: parse error (line 1)
    at [anon] (input:1) internal
    at [anon] (duk_js_compiler.c:3797) internal

First result should be 42 second = undefined third = 0

svaarala commented 1 year ago

Duktape doesn't yet support the features in the examples yet, namely: catch without a variable, ?. operator, and ?? operator.