-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-dart2wasmIssues for the dart2wasm compiler.Issues for the dart2wasm compiler.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Description
Consider this Dart script:
void main() {
print(3 == 3.0);
dynamic x = 3.0;
switch (x) {
case 0:
print('0');
case 1:
print('1');
case 2:
print('2');
case 3:
print('3');
}
}
When running it in a Dart VM, it prints
true
3
When compiled with dart2wasm
, however:
true
Uncaught (in promise) RuntimeError: illegal cast
at main (0006e8c2:0x13f6b)
at main tear-off trampoline (0006e8c2:0x13fd9)
at _invokeMain (0006e8c2:0xaba0)
at invoke (wasm.mjs:286:26)
at wasm.dart.js:9:3
The generated code shows the problem:
global.get $global787 ;; BoxedDouble { $field0: 4, $field1: 3.0 }
local.set $var3
block $label5
local.get $var3
ref.cast null $BoxedInt ;; this obviously fails
local.set $var5
loop
I've tested this with a SDK built from the current tree.
kevmoo and SleepySquash
Metadata
Metadata
Assignees
Labels
area-dart2wasmIssues for the dart2wasm compiler.Issues for the dart2wasm compiler.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)