-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dart2js generates incorrect code for 'x is int' #3814
Comments
The results of int-only operations are sometimes int and sometimes not: id(x) => x; main() { y = 2147483648 |
This comment was originally written by rice@google.com It was pointed out to me today that there's no possible test for 'int-ness' that can get the code below right. In JS, there's no way to tell the difference between a dart 'int' object and a dart 'double' that happens to have an integral value: var x = 1.0; |
We are not sure that our int tests are working well. Unfortunately, changing the int test is complicated, so it may take some time to get this changed. Also, the changes we can make initially will not allow dart2js to implement the same semantics as the VM. I think the best thing we can do for now is help you by advising on how to solve your tasks. I think for the intXX libraries you're working on, the best approach for now is to only use num when testing types. Please let us know if that causes problems. |
This comment was originally written by rice@google.com Thanks, I'll see whether I can get by with testing against 'num' in the fixnum and protobuf libraries. |
Related (possibly duplicate): issue #3720 |
Set owner to @floitschG. |
Upping the priority of this one. We're having a hard time dealing with the checked mode issues that fall out of the limited range we support for ints. Removed Priority-Medium label. |
Issue #2983 has been merged into this issue. cc @floitschG. |
Set owner to ngeoffray@google.com. |
This comment was originally written by ngeoffray@google.com Issue #4980 has been merged into this issue. cc @peter-ahe-google. |
This comment was originally written by ngeoffray@google.com We're now checking for all integers that JS can represent in its primitive number type. See https://chromiumcodereview.appspot.com/10912147/. Added Fixed label. |
This issue was originally filed by rice@google.com
The test program:
void main() {
var a = 17179869184; // 2^34
// Defeat compile-time evaluation
if (2 + 2 != 4) {
a = 2.0;
}
if (a is int) {
print("int");
} else {
print("not int");
}
}
generates code like:
$.main = function() {
var a = 17179869184;
if (typeof a === 'number' && a === (a | 0)) $.print('int');
else $.print('not int');
};
which prints 'not int' due to the unnecessary coercion applied by '(a | 0)'. This problem exists even when the checked mode compiler flag is not used.
The text was updated successfully, but these errors were encountered: