# biome style/noUselessElse: fixed output does not parse

Internal evidence sheet generated by fixhunt. Not an issue text. A human re-verifies, checks the duplicates
below, and writes the upstream report in their own words following the project's AI policy.

- Tool: biome 2.5.15
- Rule: style/noUselessElse (tool labels the fix: safe, this fix reported as safe)
- Oracle: fix-breaks-syntax
- Judge (Nemotron 3 Ultra, advisory): real, severity high. The fix hoists the `let x = 2` declaration out of the `else` block into the same scope where `let x = 1` already exists, causing a duplicate declaration SyntaxError. The documentation presents the rewrite as equivalent but does not account for block-scoped declarations that would collide when moved outward.
- Program: minimized from 9 to 7 lines

## Reproducer

```js
function f() {
  let x = 1;
  if (true) { return x; }
  else {
    let x = 2;
  }
}
```

## Commands

```sh
node prog.js
bunx @biomejs/biome lint --only=style/noUselessElse --write prog.js
node prog.js
```

## Observed

```
/home/sun/dev/diaghunt/runs/2026-10-17T19-42-12-619Z-e4vp-biome-style_noUselessElse/r2-p001/min/r2-p001-reuse/fixed.js:5
    let x = 2;
        ^

SyntaxError: Identifier 'x' has already been declared
    at checkSyntax (node:internal/main/check_syntax:84:5)

Node.js v26.8.1
```

## Diff applied by the fix

```diff
--- orig.js	2026-10-22 13:25:30.364054491 -0400
+++ fixed.js	2026-10-22 13:25:32.428088588 -0400
@@ -1,7 +1,6 @@
 function f() {
   let x = 1;
   if (true) { return x; }
-  else {
+  
     let x = 2;
-  }
 }
```

## Why the rewrite is not equivalent (model draft, verify before use)

The original code declares `x` in two separate scopes: one in the outer block (`let x = 1`) and another inside the `else` block (`let x = 2`). These are distinct variables due to lexical scoping. Removing the `else` keyword merges both declarations into the same scope—the function body—causing a duplicate declaration of `x`, which is invalid syntax. Thus, the transformation breaks correctness by violating JavaScript’s block-scoped variable rules, making the rewritten program fail to parse.

## Upstream search

Queries: "noUselessElse fix", "style noUselessElse block-scoped variable", "if-else redundant branch declaration conflict", "useless else shadowing outer scope"

- duplicate: https://github.com/biomejs/biome/issues/11937
  same rule noUselessElse removing an else block that contains a let declaration colliding with an outer let x
- related: https://github.com/biomejs/biome/issues/11351
  same class of defect safe fix breaking code but different rule useSimplifiedLogicExpression
- related: https://github.com/biomejs/biome/issues/11558
  same class of defect broken fix but different rule useExplicitLengthCheck
- related: https://github.com/biomejs/biome/issues/11092
  same rule noUselessElse but different defect double space in quick fix not declaration collision
- related: https://github.com/biomejs/biome/issues/8347
  same class of defect corrupted safe fix but different rule useConsistentArrowReturn
- related: https://github.com/biomejs/biome/issues/3770
  same rule noUselessElse but different construct else with break in loop not declaration collision
- related: https://github.com/biomejs/biome/issues/1191
  same rule noUselessElse but different construct else if with ObjectPattern not declaration collision

<details><summary>All hits</summary>

- [github, open] 💅 `noUselessElse` safe fix hoists a declaration that collides with an outer binding — https://github.com/biomejs/biome/issues/11937
- [github, open] 💅 `noUnnecessaryConditions`: false positive on an overloaded call with `undefined` as the default argument (Vue `inject`) — https://github.com/biomejs/biome/issues/12040
- [github, open] 💅 `noSkippedTests` conditionally skip fix suggestion — https://github.com/biomejs/biome/issues/9295
- [github, open] Extension chokes on large files — https://github.com/biomejs/biome/issues/3860
- [github, open] 💅 `lint/correctness/noUnusedImports` does not consider uses inside comments that precede non-declaration statements (start/end of file, etc.) — https://github.com/biomejs/biome/issues/8762
- [github, open] 💅 `useSortedClasses` cannot sort TailwindCSS classname corretly — https://github.com/biomejs/biome/issues/6498
- [github, closed] 💅 `useSimplifiedLogicExpression` "safe" fix breaks code — https://github.com/biomejs/biome/issues/11351
- [github, closed] 💅 `useExplicitLengthCheck` false positive and broken fix — https://github.com/biomejs/biome/issues/11558
- [github, closed] 💅 noUselessTernary double space in quick fix — https://github.com/biomejs/biome/issues/11092
- [github, closed] 💅 Corrupted CLI safe fix for `useConsistentArrowReturn` — https://github.com/biomejs/biome/issues/8347
- [tavily] 💅 noUselessElse reports useful else · Issue #3770 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/3770
- [tavily] 💅 `noUselessElse` recommendation is wrong · Issue #1191 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/1191
- [tavily] 🐛 Biome ignoring config? · Issue #6459 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/6459
- [tavily] 🐛 `--write` applies fixes to all rules ignoring `--only` · Issue #3470 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/3470

</details>
