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

Generic has wrong runtimeType if compiled to JS #24666

MikeMitterer opened this Issue Oct 21, 2015 · 1 comment


None yet
3 participants

MikeMitterer commented Oct 21, 2015

How you can reproduce it:
Take this sample:
Open the console and click on EVGA... (price 110.12)
You can see the result of this line:

_logger.fine("Input-Value: '$val' (${val.runtimeType}) -> '${_value}' (${_value.runtimeType})");

I use OvservableProperty for setting the value (
I take the untyped input value, check against the generic runtimeType and convert if necessary. In the above sample the input value (double) 110.12 should stay the same. This works fine with the DartVM but fails if compiled to JS.
The JS-Version returns int as runtimeType for a generic defined as double.

Here is the definition (main.dart where I define final ObservableProperty<double> total:
If you tick the checkbox then this line sets the value and produces the log output.

Output in Dartium/Chromium:

An here is Chrome:


This comment has been minimized.


sigmundch commented Oct 21, 2015

This is one of those few cases where the vm and dart2js differ by design. Dart2js' runtime types of numbers is derived from the numeric representation we get in JavaScript, where 0.0 and 0 are equivalent.

In your example, this means that an initial value of 0.0 will set initial type as int, not double.

Here is a small example that also illustrates the situation:

main() {
  var x = 1.0;

This will print double double int in the VM, but int int int in dart2js.

Making as a duplicate of #1533

@sigmundch sigmundch closed this Oct 21, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment