dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.23k stars 1.57k forks source link

Type check elimination in code generator causes erroneous type error. #11792

Closed crelier closed 9 years ago

crelier commented 11 years ago

The following program should print null without type error, even in checked mode, because null can be assigned to a malformed type variable:

null() => null; final Undeclared x = null();

main() {   print(x); }

However:

regis@belenos:~/dart3/dart$ out/DebugIA32/dart --checked ~/test.dart Unhandled exception: 'file:///usr/local/google/home/regis/test.dart': Error: line 2 pos 7: cannot resolve class name 'Undeclared' from '::' final Undeclared x = null_();       ^ type 'Null' is not a subtype of type 'malformed' of 'x'.

­0 x (file:///usr/local/google/home/regis/test.dart:2:18)

­1 main (file:///usr/local/google/home/regis/test.dart:5:10)

Now, disable type check elimination:

regis@belenos:~/dart3/dart$ out/DebugIA32/dart --no_eliminate_type_checks --checked ~/test.dart null

crelier commented 11 years ago

Cl is out for review.


Set owner to @crelier. Added Started label.

crelier commented 11 years ago

Fixed in r24962.


Added Fixed label.