Skip to content
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

Closed
sigmundch opened this issue Oct 18, 2013 · 10 comments
Closed

improve VM error messages when 2 imports collide #14202

sigmundch opened this issue Oct 18, 2013 · 10 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@sigmundch
Copy link
Member

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)

@DartBot
Copy link

DartBot commented Oct 18, 2013

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

@sigmundch
Copy link
Member Author

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:
  'a.dart': Error: line 4 pos 7: type 'Foo' is not loaded
    new Foo();
        ^
  malformed type used. Found two conflicting definitions.

@iposva-google
Copy link
Contributor

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 Priority-Unassigned label.
Added Priority-Low label.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@DartBot
Copy link

DartBot commented Apr 3, 2015

This comment was originally written by @mhausner


Removed Type-Defect label.
Added Type-Enhancement label.

@DartBot
Copy link

DartBot commented Apr 3, 2015

This comment was originally written by @mhausner


Issue #20471 has been merged into this issue.

@DartBot
Copy link

DartBot commented Apr 3, 2015

This comment was originally written by @mhausner


Issue #19571 has been merged into this issue.

@DartBot
Copy link

DartBot commented Apr 9, 2015

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.

@sigmundch sigmundch added Type-Enhancement P3 A lower priority bug or feature request area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. labels Apr 9, 2015
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed triaged labels Feb 29, 2016
@mraleph
Copy link
Member

mraleph commented Apr 24, 2018

The error will be coming from CFE now. Closing this.

@mraleph mraleph closed this as completed Apr 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

6 participants