fixhunt

biome complexity/noUselessUndefined: fix changes program behavior

fix-changes-behaviorlabelled safereal · highduplicate
Findings / 2026-10-17T20-09-08-973Z-61rc-biome-complexity_noUselessUndefined / r2-p005biome 2.5.152 → 2 lines2026-10-17 20:09 UTC

Hypothesis Nemotron 3 Super predicted not to fire fired 1×

Removing '= undefined' from parameter does not change function.length, so no behavioral difference in reflection-based code.

Program

before
1function f(a = undefined, b) {}
2console.log(f.length); // should be 2 regardless of default
after
1function f(a , b) {}
2console.log(f.length); // should be 2 regardless of default

Output

stdout beforeexit 0
0
stdout afterexit 0
2
fired
1 before · 0 after
runs
each version twice, same file name, no network

Judge Nemotron 3 Ultra advisory real · high

The rule removes the default parameter `= undefined`, which changes the function's `length` property from 0 to 2 because trailing parameters without defaults are counted. The documentation claims specifying `undefined` is useless and makes no difference, but it actually affects the function's arity metadata, a semantic change the fix does not account for.

Explanation Nemotron 3 Super unverified

The original function has two parameters; its length property counts formal parameters excluding those with defaults, so it returns 1 (only `b` counts). Removing the default makes both parameters without defaults, so length becomes 2. The change alters the function’s signature semantics, affecting a language‑defined property, thus the rewrite is not behavior‑preserving.

Reproduce

file
prog.js (the before program)
minimized program
r2-p005.js
evidence sheet
r2-p005.md
regression fixture
r2-p005.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=complexity/noUselessUndefined --write prog.js
node prog.js

Upstream search GitHub issues Tavily Nemotron 3 Super + Ultra

noUselessUndefined fix · complexity noUselessUndefined function parameter · rule complexity noUselessUndefined remove undefined default · noUselessUndefined trailing comma removal

Details

program
Function Length Reflection - No Change Expected
hazard
Removing '= undefined' from parameter does not change function.length, so no behavioral difference in reflection-based code.
oracle
stdout before: 0 stdout after: 2
run
2026-10-17T20-09-08-973Z-61rc-biome-complexity_noUselessUndefined
generated program (2 lines) and the fix's diff
1function f(a = undefined, b) {}
2console.log(f.length); // should be 2 regardless of default
--- orig.js	2026-10-17 16:09:31.089190587 -0400
+++ fixed.js	2026-10-17 16:09:31.345182068 -0400
@@ -1,2 +1,2 @@
-function f(a = undefined, b) {}
+function f(a , b) {}
 console.log(f.length); // should be 2 regardless of default
rule documentation given to the models
Summary

- Name: noUselessUndefined
- Fix: safe
- Default severity: info
- Available from version: 2.0.0
- Diagnostic category: lint/complexity/noUselessUndefined


Description

 Disallow the use of useless `undefined`.

 `undefined` is the default value for new variables, parameters, return statements, etc., so specifying it doesn't make any difference.

 `return undefined` is allowed when the enclosing function has a return type annotation other than `undefined` or `void`.

Examples

Invalid

 ```js,expect_diagnostic
 let foo = undefined;
 ```

 ```js,expect_diagnostic
 const {foo = undefined} = bar;
 ```

 ```js,expect_diagnostic
 function foo() {
    return undefined;
 }
 ```

 ```js,expect_diagnostic
 function* foo() {
   yield undefined;
 }
 ```

 ```js,expect_diagnostic
 function foo(bar = undefined) {}
 ```

 ```js,expect_diagnostic
 function foo({bar = undefined}) {}
 ```

Valid

 ```js
 let foo;
 const {foo} = bar;
 function foo() {
   return;
 }
 function* foo() {
   yield;
 }
 function foo(bar) {}
 function foo({bar}) {}
 foo();
 ```

 ```ts
 function foo(): string | undefined {
   return undefined;
 }
 ```