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
improve VM error messages when 2 imports collide #14202
Comments
This comment was originally written by @mhausner Import name conflicts in types make the type malformed and is thus mapped to dynamic. You are trying to allocate an object of a malformed type. The fact that it's malformed because of a name clash is coincidence. We had better error messages in the past but then the language was changed, turning compilation errors to runtime errors. If you want better error messages, lobby for compile time errors :-) |
would it be possible to add more details in dynamic errors though? For example, maybe we can tag why a type is malformed, so then the error could hint how to debug/fix the issue: Unhandled exception: |
You could also elect to run the other half of the compilation system and analyze your sources. It should nicely complain about this problem. Added this to the Later milestone. |
Removed this from the Later milestone. |
Removed Oldschool-Milestone-Later label. |
This comment was originally written by @mhausner Removed Type-Defect label. |
This comment was originally written by @kaendfinger This definitely seems like a good idea. Even though the analyzer will tell you, we should not leave a user scratching their head when they wrote a quick script and don't even know the analyzer exists. |
The error will be coming from CFE now. Closing this. |
Let's improve the error message when 2 imports include names that collide. When I first run into this, I had no idea I had a name conflict and I kept thinking that my import was wrong, or the name I used had a typo...
Here is a simple example with 3 files:
a.dart:
import 'b.dart';
import 'c.dart';
main() {
new Foo();
}
b.dart:
library b;
class Foo {}
c.dart:
library c;
class Foo {}
running:
dart a.dart
produces this error:Unhandled exception:
'a.dart': Error: line 4 pos 7: type 'Foo' is not loaded
new Foo();
^
malformed type used.
0 main (a.dart:4:7)
The text was updated successfully, but these errors were encountered: