fixhunt

biome style/useNumberNamespace: fix changes program behavior

fix-changes-behaviorlabelled safereal · mediumrelated
Findings / 2026-10-17T21-04-15-156Z-qk6e-biome-style_useNumberNamespace / r1-p006biome 2.5.159 → 7 lines2026-10-17 21:04 UTC

Hypothesis Nemotron 3 Super predicted to fire fired 1×

In an environment without global Number, the fix throws ReferenceError while original works (if global parseInt exists).

Program

before
1const g = Function('return this')();
2defineProperty(g, 'Number', { value: undefined });
3try {
4 console.log(parseInt('1'));
5} catch (e) {
6}
7function defineProperty(obj, name, desc) { Object.defineProperty(obj, name, desc); }
after
1const g = Function('return this')();
2defineProperty(g, 'Number', { value: undefined });
3try {
4 console.log(Number.parseInt('1'));
5} catch (e) {
6}
7function defineProperty(obj, name, desc) { Object.defineProperty(obj, name, desc); }

Output

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

Judge Nemotron 3 Ultra advisory real · medium

The rule rewrites global parseInt to Number.parseInt assuming the global Number object, but the program explicitly defines Number as undefined on the global object. This causes a runtime ReferenceError in the fixed code where the original succeeded, which is a semantic change not documented as intended.

Explanation Nemotron 3 Super unverified

The original `parseInt` refers to the global function, which remains unaffected because `g.Number` is set on a separate object (`g`) that does not shadow the global `Number`. After rewriting to `Number.parseInt`, the call accesses the `parseInt` method on the global `Number` object, but since `g.Number` was set to `undefined` and `g` is the global object (via `Function('return this')()`), the global `Number` constructor is overridden with `undefined`, making `Number.parseInt` inaccessible and causing a TypeError that is caught, resulting in no output. Thus, the change alters which `Number` is accessed, breaking semantics.

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=style/useNumberNamespace --write prog.js
node prog.js

Upstream search GitHub issues Tavily Nemotron 3 Super + Ultra

useNumberNamespace fix · style/useNumberNamespace parseInt call · useNumberNamespace global Number methods · style useNumberNamespace built-in functions

  • related biomejs/biome/issues/1228 same rule (useNumberNamespace) but about implementing the rule, not a fix-changes-behavior defect on parseInt
  • related biomejs/biome/issues/3578 same rule (useNumberNamespace) but about incorrect error message for Infinity, not parseInt fix changing behavior
  • related biomejs/biome/issues/2075 same rule (useNumberNamespace) but about isNaN replacement being a different function, not parseInt

Details

program
Environment where Number is undefined
hazard
In an environment without global Number, the fix throws ReferenceError while original works (if global parseInt exists).
oracle
stdout before: 1 stdout after:
run
2026-10-17T21-04-15-156Z-qk6e-biome-style_useNumberNamespace
generated program (9 lines) and the fix's diff
1"use strict";
2const g = Function('return this')();
3defineProperty(g, 'Number', { value: undefined });
4try {
5 console.log(parseInt('1'));
6} catch (e) {
7 console.log(e.name + ': ' + e.message);
8}
9function defineProperty(obj, name, desc) { Object.defineProperty(obj, name, desc); }
--- orig.js	2026-10-17 17:04:27.232646748 -0400
+++ fixed.js	2026-10-17 17:04:27.500649785 -0400
@@ -2,7 +2,7 @@
 const g = Function('return this')();
 defineProperty(g, 'Number', { value: undefined });
 try {
-  console.log(parseInt('1'));
+  console.log(Number.parseInt('1'));
 } catch (e) {
   console.log(e.name + ': ' + e.message);
 }
rule documentation given to the models
Summary

- Name: useNumberNamespace
- Fix: safe
- Default severity: info
- Available from version: 1.5.0
- Diagnostic category: lint/style/useNumberNamespace


Description

 Use the `Number` properties instead of global ones.

 _ES2015_ moved some globals into the `Number` properties for consistency.

 The rule doesn't report the globals `isFinite` and `isNaN` because they have a slightly different behavior to their corresponding `Number`'s properties `Number.isFinite` and `Number.isNaN`.
 You can use the dedicated rules [noGlobalIsFinite](https://biomejs.dev/linter/rules/no-global-is-finite/) and  [noGlobalIsNan](https://biomejs.dev/linter/rules/no-global-is-nan/) to enforce the use of `Number.isFinite` and `Number.isNaN`.

Examples

Invalid

 ```js,expect_diagnostic
 parseInt("1"); // true
 ```

 ```js,expect_diagnostic
 parseFloat("1.1"); // true
 ```

 ```js,expect_diagnostic
 NaN; // true
 ```

 ```js,expect_diagnostic
 Infinity; // true
 ```

 ```js,expect_diagnostic
 -Infinity; // true
 ```

Valid

 ```js
 Number.parseInt("1"); // false
 ```

 ```js
 Number.parseFloat("1.1"); // false
 ```

 ```js
 Number.NaN; // false
 ```

 ```js
 Number.POSITIVE_INFINITY; // false
 ```

 ```js
 Number.NEGATIVE_INFINITY; // false
 ```