From 001e9ec83eeea531542a14470439b8c3ad60c5d7 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 07:59:50 -0800 Subject: [PATCH] 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. --- crates/js/src/es2020_tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/js/src/es2020_tests.rs b/crates/js/src/es2020_tests.rs index db3eed5c8b..1992d52519 100644 --- a/crates/js/src/es2020_tests.rs +++ b/crates/js/src/es2020_tests.rs @@ -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"); }