BigInt(fractionalNumber) results in misleading error message
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
People
(Reporter: michalwadas, Assigned: Waldo)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0
Steps to reproduce:
Typed in console:
BigInt(2.5)
Actual results:
RangeError: can't convert non-finite number to BigInt
Expected results:
RangeError: can't convert non-integer number to BigInt
Reporter | ||
Updated•6 years ago
|
Hi michalwadas,
Thank you for your report.
I was able to reproduce it on my end on Ubuntu 18.04 (64-bit) using:
- Firefox Nightly 75.a01 (2020-02-18),
- Firefox Beta 74.0b4
- Firefox Release 71.0, 72.0.2 and 73.0.
- Firefox 68.5.0esr
I will add this issue to the DevTools - Console component so their team can take a look and give their insights on this bug.
Regards,
Virginia
Comment 2•6 years ago
|
||
Thanks for the report.
For what it's worth Chrome is displaying:
Uncaught RangeError: The number 2.3 cannot be converted to a BigInt because it is not an integer
The error we display is defined in js/src/js.msg#721 and called from js/src/vm/BigIntType.cpp#1784-1788
We can see we're only checking if the number is an integer.
Let's ask Andy and Jeff what they think of this.
Comment 3•6 years ago
|
||
To me this is indeed a bug! I think we should just change the text of the message, probably to be closer to Chrome (i.e. ideally including the value).
Assignee | ||
Comment 4•6 years ago
|
||
Updated•6 years ago
|
Assignee | ||
Updated•6 years ago
|
Comment 6•6 years ago
|
||
bugherder |
Comment 7•6 years ago
|
||
Is that a patch we should uplift to beta or can it ride the 75 train?
Assignee | ||
Comment 8•6 years ago
|
||
Subpar and even misleading error messages are not something we should be uplifting. The actual language semantics are correct (error message contents are not specified), which is what matters most. (And even if they weren't, this is fairly corner-case and would not affect most properly-written code.)
Description
•