Graaljs: Early error in arrow function

Created on 7 Aug 2020  路  4Comments  路  Source: oracle/graaljs

OS : macOS ver 10.15.3
Version: GraalVM JavaScript (GraalVM CE Native 20.1.0)

When following JavaScript codes are executed,

"use strict";
throw 42;
(...{x}) => {};
"use strict";
throw 42;
(x0, ...{x1}) => {};



md5-a91328d55991a1a11f00f8a6c3df3b5c



SyntaxError: Index: 0



md5-2dec02dfb9016370c1c5d75e58605b4b



SyntaxError: Expected an operand but found ...
(x0, ...{x1}) => {};
     ^
Expected ; but found )
(x0, ...{x1}) => {};
            ^

However, according to ECMA-262 specification(https://tc39.es/ecma262/), those are valid syntax.

Refer to (...BindingPattern) and (Expression , ...BindingPattern) rules in CoverParenthesizedExpressionAndArrowParameterList.

This works correctly on Node.js.

bug

All 4 comments

Thank you for the report. It seems that GraalJS does not parse binding patterns in rest parameters of arrow functions correctly. Unfortunately, I am not surprised to see a bug like this. The parsing of arrow functions is tricky because for a "long time" (until we encounter =>) we don't know whether we parse a parenthesized expression or an arrow function.

Hi @h2oche

thanks for all your bug reports. You made me curious - how do you find all them? Do you use fuzzing or a similar coordinated approach?

Thanks,
Christian

Hi @wirthi , I emailed you :).

Internally tracked as GR-27521

Was this page helpful?
0 / 5 - 0 ratings