util.inspect: incorrect numericSeparator formatting for numbers in scientific notation (e.g. 1e-7)
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 122k
- Forks
- 37.3k
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 283
Beschreibung
Version
v24.14.0
Platform
Linux DESKTOP-59R7A1D 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025 x86_64 GNU/Linux
Subsystem
util.inspect
What steps will reproduce the bug?
const util = require('util');
console.log(util.inspect(1e-7, { numericSeparator: true }));
How often does it reproduce? Is there a required condition?
Always reproducible when:
numericSeparatoris set totrue- The number is formatted using scientific notation (e.g.
1e-7,1e+21)
What is the expected behavior? Why is that the expected behavior?
The output should remain a valid numeric string representation.
For example:
'1e-7'
Scientific notation should either:
- remain unchanged, or
- be properly expanded before applying numeric separators
But it should never produce malformed output.
What do you see instead?
Malformed and corrupted output:
'1e-.1e-_7'
This happens because the formatting logic assumes that any non-integer number contains a decimal point (.), and attempts to split the string accordingly. However, scientific notation strings like '1e-7' do not contain a decimal point, leading to incorrect string slicing and separator insertion.
Additional information
No response
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem Einstiegspunkt util.inspect und reproduziere das bereitgestellte Beispiel für numericSeparator mit Node.js. Verfolge den Formatierungspfad für die wissenschaftliche Schreibweise und überprüfe, dass das Ergebnis weiterhin eine gültige numerische Zeichenkette ist; füge Regressionstests sowohl für 1e-7 als auch für 1e+21 hinzu, sofern die umgebenden Tests eine geeignete Stelle bieten.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, node.js
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 66/100