util.inspect: incorrect numericSeparator formatting for numbers in scientific notation (e.g. 1e-7)
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- JavaScript
- Star
- 122k
- Fork
- 37.3k
- Merge trung bình
- 4 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 283
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với điểm vào util.inspect và tái hiện ví dụ numericSeparator được cung cấp bằng Node.js. Theo dõi đường dẫn định dạng cho ký hiệu khoa học và xác minh rằng kết quả vẫn là một chuỗi số hợp lệ; thêm kiểm thử hồi quy cho cả 1e-7 và 1e+21 nếu các kiểm thử xung quanh cung cấp vị trí phù hợp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, node.js
- Lĩnh vực
- devtools
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 66/100