Skip to content

Confusing errors when there are types with the same name in different libraries #25350

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

Closed
Hixie opened this issue Jan 5, 2016 · 5 comments
Closed
Labels
devexp-ux legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@Hixie
Copy link
Contributor

Hixie commented Jan 5, 2016

import 'a.dart' as a;
import 'b.dart' as b;

void test(a.Foo foo) { }

void main() {
  b.Foo bar = new b.Foo();
  test(bar);
}
// a.dart and b.dart both look like this:
class Foo { }

Analyzer output:

Analyzing [test.dart]...
[error] Type check failed: bar (Foo) is not of type Foo (test.dart, line 8, col 8)
[warning] The argument type 'Foo (b.dart)' cannot be assigned to the parameter type 'Foo (a.dart)' (test.dart, line 8, col 8)
2 errors found.

Note how the error very confusing. The warning is great, though!

The checked-mode exception is bad too:

Unhandled exception:                                                                                                                                                                                            
type 'Foo' is not a subtype of type 'Foo' of 'foo'.                                                                                                                                                             
#0      test (test.dart:4:17)
#1      main (test.dart:8:3)
#2      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:263)
#3      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:150)
@bwilkerson
Copy link
Member

@jmesserly Is there any reason to have both an error and a warning for the same problem? I'm guessing not and that this is just part of the strong-mode integration work that isn't quite complete yet.

@jmesserly
Copy link

Yeah, one message is from CodeChecker and another is from ErrorVerifier.

I believe we can remove CodeChecker's type check messages, but we need to do double check that ErrorVerifier will produce a message every time CodeChecker would have. A nice bonus here is that ErrorVerifier's messages are friendlier.

@bwilkerson do you mind if I leave this unassigned? I'm not sure if I will work on it or @leafpetersen or @vsmenon.

@jmesserly jmesserly removed their assignment Jan 5, 2016
@bwilkerson
Copy link
Member

do you mind if I leave this unassigned?

Nope.

@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed Priority-Medium labels Mar 1, 2016
@munificent
Copy link
Member

This is fixed by 2ef00b0. The redundant (and hard to understand) strong mode error is gone now and only the warning remains.

@Hixie
Copy link
Contributor Author

Hixie commented Mar 15, 2016

Sweet! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-ux legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants