biome complexity/noUselessUndefined: fix changes program behavior
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
Output
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
- duplicate biomejs/biome/issues/11934 same rule removing `= undefined` default parameter and changing function `length`
- related biomejs/biome/issues/12040 same rule but different construct (overloaded call with undefined default)
- related biomejs/biome/issues/11017 same rule `noUselessUndefined` but different conflict (TypeScript TS7030)
- related biomejs/biome/issues/6906 same rule `noUselessUndefined` but different construct (union return types)
- related biomejs/biome/issues/6611 same rule `noUnnecessaryConditions` mentioned but different construct (overloaded calls)
- related biomejs/biome/issues/6577 same rule `noUselessUndefined` but different construct (false positive report)
- related biomejs/biome/issues/6578 same rule `noUselessUndefined` but different construct (parameter flagging)
- related biomejs/biome/issues/3942 same rule `noUselessUndefined` implementation tracking issue
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
--- 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;
}
```