biome style/noNegationElse: fixed output does not parse
Hypothesis Nemotron 3 Super predicted to fire fired 1×
ASI and semicolon-less code, leading ( or [ on the next line
Program
Output
(no stdout) TypeError: "" is not a function
(no stdout) TypeError: "" is not a function
- fired
- 1 before · 0 after
- runs
- each version twice, same file name, no network
Judge Nemotron 3 Ultra advisory real · high
The fix incorrectly rewrites an if-else statement without braces by negating the condition and swapping branches, but produces invalid syntax 'if (foo) result += 'B' else result += 'A'' which is a syntax error. The rule documentation presents this rewrite as safe and equivalent, but the transformation fails to account for the required braces when an else clause exists, causing the fixed file to no longer parse.
Explanation Nemotron 3 Super unverified
The rewrite inverts the condition but incorrectly swaps branches without preserving logical equivalence; it also introduces invalid syntax due to missing braces around the else clause, causing a parse error before execution can occur, so behavior differs both syntactically and semantically from the original.
Reproduce
- file
prog.js(the before program)- minimized program
- r2-p001.js
- evidence sheet
- r2-p001.md
- regression fixture
- r2-p001.js the minimized program with a header stating the observed change, for the tool's test suite
node prog.js bunx @biomejs/biome lint --only=style/noNegationElse --write prog.js node prog.js
Upstream search GitHub issues Tavily Nemotron 3 Super + Ultra
noNegationElse fix · style noNegationElse if negation · biome style/noNegationElse conditional expression · rule style/noNegationElse else clause syntax
- related biomejs/biome/issues/9629 same rule noNegationElse but different construct ternary with comments
- related biomejs/biome/issues/7518 same rule noNegationElse but generic fix-breaks-syntax without construct details
- related biomejs/biome/issues/691 same rule noNegationElse mentioned in config but no defect details
Details
- program
- ASI Hazard: Leading Parentheses
- hazard
- ASI and semicolon-less code, leading ( or [ on the next line
- oracle
/home/sun/dev/diaghunt/runs/2026-10-17T20-56-43-558Z-ibkb-biome-style_noNegationElse/r2-p001/min/r2-p001-reuse/fixed.js:4 result += 'B' else ^^^^ SyntaxError: Unexpected token 'else' at checkSyntax (node:internal/main/check_syntax:84:5) Node.js v26.8.1- run
- 2026-10-17T20-56-43-558Z-ibkb-biome-style_noNegationElse
generated program (11 lines) and the fix's diff
--- orig.js 2026-10-17 16:57:17.310306347 -0400 +++ fixed.js 2026-10-17 16:57:17.583310129 -0400 @@ -1,10 +1,9 @@ let result = '' (() => { - if (!foo) + if (foo) + result += 'B' else result += 'A' - else - result += 'B' })() function foo() { return false }
rule documentation given to the models
Summary
- Name: noNegationElse
- Fix: safe
- Default severity: info
- Available from version: 1.0.0
- Diagnostic category: lint/style/noNegationElse
Description
Disallow negation in the condition of an `if` statement if it has an `else` clause.
Examples
Invalid
```js,expect_diagnostic
if (!cond) { f();} else { g();}
```
```js,expect_diagnostic
!cond ? 0 : 1
```
Valid
```js
if (!cond) { f(); }
```
```js
cond ? 1 : 0
```
```js
if (!cond) { f(); }
```
```js
if (!!val) { f(); } else { g(); }
```