1
Fork 0
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:
Andreas Kling 2020-03-28 11:48:52 +01:00
parent f1a074a262
commit 14de45296e
2 changed files with 26 additions and 5 deletions

View 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);
}