mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:07:35 +00:00
LibJS: Fix broken parsing of !o.a
Unary expressions parsing now respects precedence and associativity of operators. This patch also makes `typeof` left-associative which was an oversight. Thanks to Conrad for helping me work this out. :^)
This commit is contained in:
parent
f1a074a262
commit
14de45296e
2 changed files with 26 additions and 5 deletions
18
Libraries/LibJS/Tests/parser-unary-associativity.js
Normal file
18
Libraries/LibJS/Tests/parser-unary-associativity.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var o = {};
|
||||
o.a = 1;
|
||||
|
||||
assert(o.a === 1);
|
||||
assert(!o.a === false);
|
||||
assert(!o.a === !(o.a));
|
||||
assert(~o.a === ~(o.a));
|
||||
|
||||
assert((typeof "x" === "string") === true);
|
||||
assert(!(typeof "x" === "string") === false);
|
||||
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue