Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

dart2js and spec disagree about numerics #1533

Open
sethladd opened this Issue · 19 comments
@sethladd
Owner

The following Dart code:

var x = 123;
print(x is! double);

will print TRUE in Dart VM and FALSE in JavaScript compiled from Frog.

The generated JavaScript code in question:

print((typeof(x) != 'number'));

doesn't match the intention of the original Dart code.

@DartBot
Collaborator

This comment was originally written by jat@google.com


See also issue #638 and lengthy discussions on the mailing list last year.

@dgrove
Owner

Added Area-Frog, Triaged labels.

@gbracha
Collaborator

I'm generalizing this to tack the numeric discrepancies between the spec (and VM) and the Javascript based implementations.

Consider:

main() {
    int billion = 1000000000;
    int quintillion = billion * billion;
    int quintillionOne = quintillion + 1;
    print(quintillion == quintillionOne);
  }

It compiles without emitting a warning or error, and prints true, which clearly violates the principle of least astonishment.

WE may end up making allowances for JS in some way, but for now this is a bug, and we can track the issue here.


Changed the title to: "Frog and spec disagree about numerics".

@anders-sandholm

Removed Area-Frog label.
Added Area-Dart2JS, FromAreaFrog labels.

@kasperl
Collaborator

Removed FromAreaFrog label.
Changed the title to: "dart2js and spec disagree about numerics".

@DartBot
Collaborator

This comment was originally written by la...@randompage.org


We need arbitrary precision integers in our Dart program and have currently implemented our own integer class to get around this bug. Arbitrary precision makes sense for a modern programming language as it's would cause numeric overflows to be a thing of the past.

At any rate please provide some closure on if Dart's integers are arbitrary precision or not.

@sethladd
Owner

The spec says that integers are arbitrary precision. The open issue is how will dart2js accomplish this, with reasonable performance.

@floitschG
Collaborator

Issue #4478 has been merged into this issue.

@sethladd
Owner

Added this to the M1 milestone.
Removed Priority-Medium label.
Added Priority-High label.

@kasperl
Collaborator

We do not plan to change the way we deal with ints in dart2js for M1. We will take a look at tackling issue #3814 and issue #4437, but general big int support is *not* something we're ready to tackle anytime soon.

It remains an issue so I'm certainly keeping the bug open.


Set owner to @kasperl.
Removed this from the M1 milestone.
Added this to the Later milestone.
Removed Priority-High label.
Added Priority-Medium, Accepted labels.

@kasperl
Collaborator

cc @larsbak.

@floitschG
Collaborator

Issue #5827 has been merged into this issue.

@kasperl
Collaborator

Removed this from the Later milestone.

@kasperl
Collaborator

Added this to the Later milestone.

@DartBot
Collaborator

This comment was originally written by ngeoffray@google.com


Issue #6627 has been merged into this issue.


cc @karlklose.

@fsc8000
Collaborator

Issue #6627 has been merged into this issue.

@rakudrama
Collaborator

Issue #6627 has been merged into this issue.

@peter-ahe-google
Collaborator

Issue #7488 has been merged into this issue.

@gramster

For the record, I would like to note that merging bugs like 7488 and others with 1533 is fine as long as those other bugs are revisited when addressing this issue, as this issue seems to have largely become about whether dart2js will support bigints, and I don't think that that is the same as what issue #7488 is about, namely doubles without fractional parts being treated as ints by dart2js (and thus being legitimately used, for example, as indices into containers, while the VM will throw an exception).

@floitschG floitschG was assigned by sethladd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.