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.2k stars 1.57k forks source link

Confusing error message in checked mode #5067

Closed DartBot closed 9 years ago

DartBot commented 12 years ago

This issue was originally filed by ngeoffray@google.com


$ cat foo.dart final int x = 'string'; main() => print(x); $ ./out/ReleaseIA32/dart --enable-type-checks foo.dart Unhandled exception: type 'String' is not a subtype of type 'int' of 'function result'.

­0 x (file:///usr/local/google/home/ngeoffray/projects/dart2/dart/foo.dart:1:15)

'file:///usr/local/google/home/ngeoffray/projects/dart2/dart/foo.dart': Error: line 2 pos 18: error initializing final field 'x' main() => print(x);

What is 'function result'?

iposva-google commented 12 years ago

Set owner to @crelier. Added this to the M2 milestone. Added Accepted label.

crelier commented 11 years ago

The way finals are initialized have changed and I cannot reproduce a case with this error message. Instead, I get:

type 'String' is not a subtype of type 'int' of 'x'.

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

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

Feel free to reopen this bug if you find a test case.


Added CannotReproduce label.