# biome complexity/noUselessUndefined: fix changes program behavior

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: complexity/noUselessUndefined (tool labels the fix: safe, this fix reported as safe)
- Oracle: fix-changes-behavior
- Judge (Nemotron 3 Ultra, advisory): real, severity high. The rule removes the initializer `undefined` from `let x = undefined`, turning it into `let x;`. In the program, a local variable named `undefined` shadows the global `undefined` with the value 42, so the original code assigns 42 to `x`. After the fix, `x` receives the true global `undefined`, changing the program's output from `42` to `undefined`. The documentation presents the rewrite as equivalent and does not mention shadowing, so this is an unsafe fix for a plausible construct.
- Program: minimized from 20 to 10 lines

## Reproducer

```js
let log = [];
(function(){ 
  var undefined = 42; // shadowing
  let x = undefined;  // rule triggers: removes this line
  log.push(String(x));
})();
try {
} catch(e) {
}
console.log(log.join(' | '));
```

## Commands

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

## Observed

```
stdout before:
42
stdout after:
undefined
```

## Diff applied by the fix

```diff
--- orig.js	2026-10-22 13:25:57.403501512 -0400
+++ fixed.js	2026-10-22 13:25:59.451535399 -0400
@@ -1,7 +1,7 @@
 let log = [];
 (function(){ 
   var undefined = 42; // shadowing
-  let x = undefined;  // rule triggers: removes this line
+  let x ;  // rule triggers: removes this line
   log.push(String(x));
 })();
 try {
```

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

The original code shadows the global `undefined` with a local variable initialized to 42 via `var undefined = 42`. The line `let x = undefined;` then assigns that local value (42) to `x`, so `String(x)` becomes `"42"`. After removal of the initializer, `let x;` declares `x` without initializing it, leaving it as the actual `undefined` value (since the local `undefined` variable is not a type but a variable name). Thus `String(x)` yields `"undefined"`, changing the output from `"42"` to `"undefined"`. The rewrite incorrectly assumes the identifier refers to the global `undefined` value, ignoring the lexical shadowing. This violates semantics because the initializer’s value depends on the scoped binding, not a predefined constant. Removing it alters the program’s state.

## Upstream search

Queries: "noUselessUndefined fix", "complexity noUselessUndefined variable declaration", "shadowed global undefined assignment removal", "unused undefined reference elimination"

- related: https://github.com/biomejs/biome/issues/11934
  same rule but different construct (parameter default vs variable declaration with shadowed undefined)
- related: https://github.com/biomejs/biome/issues/11017
  same rule (noUselessUndefined) but different construct (TypeScript noImplicitReturns conflict)
- related: https://github.com/biomejs/biome/issues/6906
  same rule (noUselessUndefined) but different construct (union return types in functions)

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

- [github, open] 💅 `noUselessUndefined` safe fix removes `= undefined` parameter defaults, changing `arguments` and `length` — https://github.com/biomejs/biome/issues/11934
- [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, closed] 💅 `noUselessReturn` safe fix removes a final `return;` that TypeScript's `noImplicitReturns` needs (TS7030) — https://github.com/biomejs/biome/issues/11903
- [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, closed] 💅 `noUselessUndefined` conflicts with `ts(7030)` — https://github.com/biomejs/biome/issues/11017
- [github, closed] 💅 lint/nursery/noUselessUndefined fix is unsafe for functions with union return types — https://github.com/biomejs/biome/issues/6906
- [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] 💅 `useExplicitLengthCheck` false positive — https://github.com/biomejs/biome/issues/11352
- [github, closed] 💅 Corrupted CLI safe fix for `useConsistentArrowReturn` — https://github.com/biomejs/biome/issues/8347
- [tavily] 🐛 `biome.json` JSON schema for 2.1.X requires specifying `options` for rules if `fix` is given · Issue #7217 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7217
- [tavily] 📎 Implement `noUnnecessaryConditions` · Issue #6611 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/6611
- [tavily] 💅 noParametersOnlyUsedInRecursion false positives · Issue #8004 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8004
- [tavily] 💅 `useAwaitThenable` many false positives with drizzle · Issue #8476 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8476
- [tavily] 💅 `2.3.14` introduces incorrect behavior to `useExhaustiveDeps` · Issue #8958 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8958
- [tavily] 💅 `noUnknownAttribute` doesn't support SVG opacity · Issue #7967 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7967
- [tavily] 💅 nursery/noMisusedPromises causes stack overflow · Issue #6777 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/6777
- [tavily] 🐛 `noFloatingPromises` inconsistent behavior in 2.5.8+ · Issue #11529 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/11529
- [tavily] 💅 Using object literal shorthand syntax causes useErrorCause false positive · Issue #10664 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/10664
- [tavily] 💅 `useDestructuring` doesn't work with type annotations · Issue #8478 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8478
- [tavily] 💅 gql formatter crashing · Issue #9131 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/9131

</details>
