Closed Bug 1615600 Opened 6 years ago Closed 6 years ago

BigInt(fractionalNumber) results in misleading error message

Categories

(Core :: JavaScript Engine, defect)

73 Branch
defect
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla75
Tracking Status
firefox-esr68 --- wontfix
firefox73 --- wontfix
firefox74 --- wontfix
firefox75 --- fixed

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

Severity: normal → minor

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

Status: UNCONFIRMED → NEW
Component: Untriaged → Console
Ever confirmed: true
Product: Firefox → DevTools

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.

Component: Console → JavaScript Engine
Flags: needinfo?(wingo)
Flags: needinfo?(jwalden)
Product: DevTools → Core

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).

Flags: needinfo?(wingo)
Assignee: nobody → jwalden
Status: NEW → ASSIGNED
Flags: needinfo?(jwalden)
Pushed by jwalden@mit.edu: https://hg.mozilla.org/integration/autoland/rev/499d0e825c87 Use a better error message for when an attempt is made to convert a non-integer number to a BigInt. r=wingo
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla75

Is that a patch we should uplift to beta or can it ride the 75 train?

Flags: needinfo?(jwalden)

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.)

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: