Skip to content

Annex B: f() = g() in non-strict mode raises SyntaxError at parse; should be runtime ReferenceError #5374

Description

@Oichkatzelesfrettschen

Annex B sec-runtime-errors-for-function-call-assignment-targets requires that CallExpression as an assignment LHS in non-strict code is valid syntax that throws ReferenceError at runtime. Boa rejects it at parse time.

Repro (non-strict):

function f() { return {}; }
function g() { return 1; }
f() = g();   // should throw ReferenceError at runtime
f() += 1;
++f();
f()++;
for (f() in []) {}

Expected: ReferenceError at runtime
Got: SyntaxError: Invalid left-hand side in assignment at parse time

Spec: https://tc39.es/ecma262/#sec-runtime-errors-for-function-call-assignment-targets

Fix: In the parser, when the LHS of an assignment is a CallExpression in non-strict mode, accept the syntax and emit a runtime ReferenceError instead of a parse error.

Failing test262: annexB/language/expressions/assignmenttargettype/ (7 cases)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions