Skip to content

util.inspect: fix numericSeparator for scientific notation numbers#62987

Open
AmSach wants to merge 1 commit intonodejs:mainfrom
AmSach:fix/inspect-sci-not-numeric-sep
Open

util.inspect: fix numericSeparator for scientific notation numbers#62987
AmSach wants to merge 1 commit intonodejs:mainfrom
AmSach:fix/inspect-sci-not-numeric-sep

Conversation

@AmSach
Copy link
Copy Markdown

@AmSach AmSach commented Apr 27, 2026

Fixes #62981

When numericSeparator: true is set, util.inspect produces corrupted output like '1e-.1e-_7' for numbers in scientific notation (e.g. 1e-7).

The fix adds an early return for scientific notation strings before the decimal-split + numeric separator logic runs.

When numericSeparator: true is set, util.inspect produces corrupted
output like '1e-.1e-_7' for numbers in scientific notation (e.g. 1e-7).

The fix adds an early return for scientific notation strings before
the decimal-split + numeric separator logic runs.

Fixes nodejs#62981
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Apr 27, 2026
Copy link
Copy Markdown
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are needed.

return base;
return ctx.stylize(base, StringPrototypeToLowerCase(type));
if (constructor !== null) {
const superName = ObjectGetPrototypeOf(value).name;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would a [[Prototype]] object necessarily have a .name? and why would a class-related change belong in a PR fixing number display?

Comment on lines -2417 to +2431
ctx.indentationLvl += 2;
let i = 0;
ctx.indentationLvl += 2;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls revert this, it's unrelated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

util.inspect: incorrect numericSeparator formatting for numbers in scientific notation (e.g. 1e-7)

3 participants