mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 08:08:43 +00:00
LibJS: Apply the correct precedence for unary + and - operators
When determining the precedence of the + and - operators, the parser always returned the precedence using these operators in a binary expression (lower than division!). The context of whether the operator is used in a unary or binary expression must be taken into account.
This commit is contained in:
parent
18c54d8d40
commit
073eb46824
Notes:
sideshowbarker
2024-07-17 06:54:15 +09:00
Author: https://github.com/samkravitz 🔰
Commit: 073eb46824
Pull-request: https://github.com/SerenityOS/serenity/pull/20419
Reviewed-by: https://github.com/awesomekling
2 changed files with 17 additions and 1 deletions
|
@ -12,3 +12,7 @@ test("basic functionality", () => {
|
|||
expect((typeof "x" === "string") === true).toBeTrue();
|
||||
expect(!(typeof "x" === "string") === false).toBeTrue();
|
||||
});
|
||||
|
||||
test("unary +/- operators bind higher than binary", () => {
|
||||
expect(10 ** -3 / 2).toEqual(0.0005);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue