• Apparently whenever an inner arrow function has a parenthesised parameter list, a parse error is thrown. This is a minimal reproduction; real code is likewise affected:

    In the REPL of the Bangle emulator:

    >x=>(y)=>0
    Uncaught SyntaxError: Got => expected EOF
     at line 1 col 7
    x=>(y)=>0
          ^
    >
    

    But per https://262.ecma-international.org/12.0/­#prod-AssignmentExpression

    AssignmentExpression: … | ArrowFunction | …;
    ArrowFunction: ArrowParameters => ConciseBody;
    ArrowParameters: BindingIdentifier | CoverParenthesizedExpressionAndArrowPara­meterList;
    BindingIdentifier: Identifier | …;
    CoverParenthesizedExpressionAndArrowPara­meterList: ( Expression ) | …;
    ConciseBody: [Lookahead ≠ {] ExpressionBody | …;
    ExpressionBody: AssignmentExpression;

    The parser is thus not supposed to commit early to whether “(…” starts an expression or an arrow function, whether or not we are already inside an arrow function. And, indeed, other interpreters I've tried have no such problem.

    There is of course a workaround, to use full function syntax for the inner function, but (and here I cannot intuit what is going wrong), parenthesising the inner function does not work, producing any of a variety of strange errors.

About