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
commit 14de45296e
Notes: sideshowbarker 2024-07-19 08:05:55 +09:00
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);
}