Skip to content

dart2js computes some number operations with non-web semantics #44818

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
vsmenon opened this issue Jan 31, 2021 · 1 comment
Closed

dart2js computes some number operations with non-web semantics #44818

vsmenon opened this issue Jan 31, 2021 · 1 comment
Assignees
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. web-dart2js

Comments

@vsmenon
Copy link
Member

vsmenon commented Jan 31, 2021

The following:

void main() {
  final list = [];
  for (var i = 0; i < 1; i++) {
    list.add(((i * 2) / 2).runtimeType);
  } 
  
  final item = (((0 * 2) / 2).runtimeType);
  
  print(list.first);
  print(item);
}

prints double and int in dart2js (2.10.4 - current dartpad).

For the former, it generates:

C.JSDouble_methods.get$runtimeType(i * 2 / 2);

which appears to unconditionally return double (

Type get runtimeType => double;
).

For the latter, it generates:

C.JSInt_methods.get$runtimeType(0)
@vsmenon vsmenon added web-dart2js area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. labels Jan 31, 2021
@vsmenon
Copy link
Member Author

vsmenon commented Feb 4, 2021

@rakudrama - would changing runtimeType in JSDouble to something like:

  Type get runtimeType => JS(...) ? int : double;

make sense here?

@rakudrama rakudrama self-assigned this Feb 6, 2021
dart-bot pushed a commit that referenced this issue Feb 9, 2021
JSDouble was really "double *excluding integral values*".
This was confusing, with JSDouble sometimes used assuming it was all doubles.
Rename JSDouble to JSNumNotInt to avoid future errors like #44818

Change-Id: I96bf33d5531b94aaf33b582e584702f47ed50395
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183201
Commit-Queue: Stephen Adams <[email protected]>
Reviewed-by: Sigmund Cherem <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. web-dart2js
Projects
None yet
Development

No branches or pull requests

2 participants