mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 04:33:43 +00:00
JavaScript: the ?? precedence test tells the two groupings apart
`(null ?? 1 | 2)` and `(null ?? 0 ? 'a' : 'b')` give the same result under either grouping. `(1 ?? 2 | 4)` gives 5 and `(1 ?? 0 ? 'a' : 'b')` gives 1 when `??` binds the wrong way, so the test now fails on a wrong precedence.
This commit is contained in:
@@ -137,8 +137,8 @@ fn coalesce_takes_the_right_side_only_for_undefined_or_null() {
|
||||
|
||||
#[test]
|
||||
fn coalesce_binds_looser_than_bitwise_and_tighter_than_the_conditional() {
|
||||
truth("(null ?? 1 | 2) === 3");
|
||||
truth("(null ?? 0 ? 'a' : 'b') === 'b'");
|
||||
truth("(1 ?? 2 | 4) === 1");
|
||||
truth("(1 ?? 0 ? 'a' : 'b') === 'a'");
|
||||
truth("var x = null ?? 7, y = 1 ?? 8; x === 7 && y === 1");
|
||||
truth("((null || 1) ?? 2) === 1 && (null ?? (0 && 1)) === 0 && ((0 ?? 1) || 2) === 2 && ((null && 1) ?? 2) === 2");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user