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)
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