mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 18:50:50 +00:00
LibJS: Check AssignmentExpression LHS in parser
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.
This commit is contained in:
parent
063228c02e
commit
d69ed91790
Notes:
sideshowbarker
2024-07-19 06:41:27 +09:00
Author: https://github.com/linusg
Commit: d69ed91790
Pull-request: https://github.com/SerenityOS/serenity/pull/2205
Issue: https://github.com/SerenityOS/serenity/issues/2204
3 changed files with 11 additions and 9 deletions
|
@ -1,22 +1,17 @@
|
|||
load("test-common.js");
|
||||
|
||||
try {
|
||||
function foo() { }
|
||||
|
||||
assertThrowsError(() => {
|
||||
512 = 256;
|
||||
foo() = "foo";
|
||||
}, {
|
||||
error: ReferenceError,
|
||||
message: "Invalid left-hand side in assignment"
|
||||
});
|
||||
|
||||
assertThrowsError(() => {
|
||||
512 = 256;
|
||||
}, {
|
||||
error: ReferenceError,
|
||||
message: "Invalid left-hand side in assignment"
|
||||
});
|
||||
|
||||
assertThrowsError(() => {
|
||||
"hello world" = "another thing?";
|
||||
(function () { })() = "foo";
|
||||
}, {
|
||||
error: ReferenceError,
|
||||
message: "Invalid left-hand side in assignment"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue