biome complexity/useFlatMap: fix changes program behavior
Hypothesis Nemotron 3 Super predicted to fire fired 1×
arguments object, function.length, default parameters, rest parameters
Program
Output
(no stdout) TypeError: arguments.map is not a function
(no stdout) TypeError: arguments.flatMap is not a function
- fired
- 1 before · 0 after
- runs
- each version twice, same file name, no network
Judge Nemotron 3 Ultra advisory program-bug · low
The program fails both before and after the fix because `arguments` is an array-like object without `map` or `flatMap` methods. The rewrite does not change the error; the failure is unrelated to the rule's transformation.
Explanation Nemotron 3 Super unverified
The `arguments` object is array-like but lacks built-in methods like `.map` or `.flatMap`. Both versions attempt to call these methods directly on `arguments`, which fails because they are not defined on the arguments object. The error changes from `arguments.map is not a function` to `arguments.flatMap is not a function`, but the underlying issue remains: neither method exists on `arguments`. Thus, the rewrite does not fix the core problem and still throws a TypeError, preserving the failure mode rather than correcting it. The behavior differs only in which method name appears in the error, not in semantic correctness.
Reproduce
- file
prog.js(the before program)- minimized program
- r1-p006.js
- evidence sheet
- r1-p006.md
- regression fixture
- r1-p006.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/useFlatMap --write prog.js node prog.js
Upstream search GitHub issues Tavily Nemotron 3 Super + Ultra
useFlatMap fix · biome complexity/useFlatMap arguments map flat · biome complexity/useFlatMap arguments flatMap replacement · biome complexity/useFlatMap rest parameters usage
- related biomejs/biome/issues/1768 same rule (useFlatMap) but different construct (array literal vs arguments object)
- related biomejs/biome/issues/2817 same rule (useFlatMap) mentioned but different construct (string functions vs array flatMap)
- related biomejs/biome/issues/1744 same rule (useFlatMap) but different construct (LSP diagnostics severity vs arguments object)
- related biomejs/biome-vscode/issues/241 same rule (useFlatMap) but different construct (format-on-save garbling vs arguments object)
Details
- program
- Arguments Object and Parameters
- hazard
- arguments object, function.length, default parameters, rest parameters
- oracle
stderr before: TypeError: arguments.map is not a function stderr after: TypeError: arguments.flatMap is not a function- run
- 2026-10-17T20-12-00-746Z-4q9e-biome-complexity_useFlatMap
generated program (5 lines) and the fix's diff
--- orig.js 2026-10-17 16:12:13.830635639 -0400 +++ fixed.js 2026-10-17 16:12:14.086629700 -0400 @@ -1,5 +1,5 @@ function process(a, b = [], ...rest) { - return arguments.map(x => [x]).flat(); + return arguments.flatMap(x => [x]); } const res = process(1, 2, 3); console.log(res.length, res.join(','));
rule documentation given to the models
Summary
- Name: useFlatMap
- Fix: safe
- Default severity: info
- Available from version: 1.0.0
- Diagnostic category: lint/complexity/useFlatMap
- This rule is recommended
Description
Promotes the use of `.flatMap()` when `map().flat()` are used together.
Using `.flatMap()` instead of `map().flat()` avoids the creation of
an intermediate array.
Examples
Invalid
```js,expect_diagnostic
const array = ["split", "the text", "into words"];
array.map(sentence => sentence.split(' ')).flat();
```
```js,expect_diagnostic
const array = ["split", "the text", "into words"];
array.map(sentence => sentence.split(' ')).flat(1);
```
Valid
```js
const array = ["split", "the text", "into words"];
array.map(sentence => sentence.split(' ')).flat(2);
```