Skip to content

dart2js bug with Random.nextInt((1<<32)-1) #5827

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

Closed
DartBot opened this issue Oct 12, 2012 · 3 comments
Closed

dart2js bug with Random.nextInt((1<<32)-1) #5827

DartBot opened this issue Oct 12, 2012 · 3 comments
Labels
closed-duplicate Closed in favor of an existing report web-dart2js
Milestone

Comments

@DartBot
Copy link

DartBot commented Oct 12, 2012

This issue was originally filed by [email protected]


What steps will reproduce the problem?

  1. Use the code :

import('dart:math');

num newId(){
  var id = new Random();
  return id.nextInt((1<<32)-1);
}

main(){
  var id = newId();
  print(id);
}

  1. Run dart2js
  2. Launch with Chrome

What is the expected output? What do you see instead?

I expect a random integer.
I see nothing.

What version of the product are you using? On what operating system?

Dart Edidor Version 0.1.0.201210082016, build 13393
Dart SDK version 13387
OS : ubuntu 12.04 64bits

Please provide any additional information below.

The code above works with Dart alone, but the javascript version doesn't.
If we replace (1<<32)-1 by (1<<31)-1 the javascript works.

@kasperl
Copy link

kasperl commented Oct 12, 2012

Added this to the M2 milestone.
Added Area-Dart2JS, Triaged labels.

@kasperl
Copy link

kasperl commented Oct 12, 2012

cc @floitschG.

@floitschG
Copy link
Contributor

Unfortunately this is currently working as intended. When compiling to JavaScript, bit-operations are limited to 32 bits (therefore marking this bug as duplicate of bug 1533).

Normally this shouldn't just silently exit but throw an exception (since (1 << 31) - 1 becomes -1). If you don't get any exception please reopen with more information and I will investigate further.


Added Duplicate label.
Marked as being merged into #1533.

@DartBot DartBot added Type-Defect web-dart2js closed-duplicate Closed in favor of an existing report labels Oct 12, 2012
@DartBot DartBot added this to the M2 milestone Oct 12, 2012
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-duplicate Closed in favor of an existing report web-dart2js
Projects
None yet
Development

No branches or pull requests

3 participants