Skip to content

Fix operator precedence in fuzzyScore2 test assertion#304449

Merged
bpasero merged 2 commits intomicrosoft:mainfrom
ShehabSherif0:fix/fuzzy-scorer-test-nullish-precedence
Mar 25, 2026
Merged

Fix operator precedence in fuzzyScore2 test assertion#304449
bpasero merged 2 commits intomicrosoft:mainfrom
ShehabSherif0:fix/fuzzy-scorer-test-nullish-precedence

Conversation

@ShehabSherif0
Copy link
Copy Markdown
Contributor

Fixes #304448

The >= operator (precedence 11) binds tighter than ?? (precedence 5), so multiScore ?? 0 >= (sum) parses as multiScore ?? (0 >= sum). When multiScore is a positive number, ?? short-circuits and assert.ok(positiveNumber) always passes without evaluating the comparison.

Before: assert.ok(multiScore ?? 0 >= ((firstSingleScore ?? 0) + (secondSingleScore ?? 0)))
After: assert.ok((multiScore ?? 0) >= ((firstSingleScore ?? 0) + (secondSingleScore ?? 0)))

Copilot AI review requested due to automatic review settings March 24, 2026 12:51
@vs-code-engineering vs-code-engineering bot added this to the 1.114.0 milestone Mar 24, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a false-positive assertion in the fuzzy scoring unit tests by correcting operator precedence so the intended >= comparison is always evaluated.

Changes:

  • Parenthesized (multiScore ?? 0) in assert.ok(...) to ensure ?? is applied before >=.

@TomGousseau
Copy link
Copy Markdown

sqsq0(2)

@bpasero bpasero merged commit c425760 into microsoft:main Mar 25, 2026
25 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Operator precedence bug in fuzzyScore2 test assertion - comparison never evaluated

7 participants