
There are many cases which shouldn't even parse, like null = ... true = ... false = ... 123 = ... "foo" = ... However this *is* valid syntax: foo() = ... So we still have to keep the current code doing a runtime check if the LHS value is a resolvable reference. I believe this was declared valid syntax to *in theory* allow functions returning references - though in practice that isn't a thing. Fixes #2204.
23 lines
457 B
JavaScript
23 lines
457 B
JavaScript
load("test-common.js");
|
|
|
|
try {
|
|
function foo() { }
|
|
|
|
assertThrowsError(() => {
|
|
foo() = "foo";
|
|
}, {
|
|
error: ReferenceError,
|
|
message: "Invalid left-hand side in assignment"
|
|
});
|
|
|
|
assertThrowsError(() => {
|
|
(function () { })() = "foo";
|
|
}, {
|
|
error: ReferenceError,
|
|
message: "Invalid left-hand side in assignment"
|
|
});
|
|
|
|
console.log("PASS");
|
|
} catch (e) {
|
|
console.log("FAIL: " + e);
|
|
}
|