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

Unactionable "has inferred type" hint with typedefs #24710

Closed
Hixie opened this issue Oct 23, 2015 · 5 comments
Closed

Unactionable "has inferred type" hint with typedefs #24710

Hixie opened this issue Oct 23, 2015 · 5 comments
Assignees
Labels
analyzer-ux area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on

Comments

@Hixie
Copy link
Contributor

Hixie commented Oct 23, 2015

typedef String Test(String arg);

String test1(String arg) => '1';
String test2(String arg) => '2';

void main() {
  Test test = test1;
  test = test == test1 ? test2 : test1;"                                                                                                                                                                      
}
Analyzing [test.dart]...
[hint] test == test1 ? test2 : test1 has inferred type (String) → String (test.dart, line 8, col 10)
1 hint found.

I don't know what the analyzer wants me to do here. Give it a pat on the head? (Apologies if this is one of the strong mode hints that was recently removed. We haven't yet revved the SDK.)

I think my ideal resolution here would be to replace this hint with a warning that fires whenever you have an implied type (e.g. when you haven't specialised a list literal, or when you call the Map constructor without specialising it, or when you use var or don't explicitly type a property or argument).

@bwilkerson bwilkerson added Type-Defect area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-ux labels Oct 23, 2015
@bwilkerson
Copy link
Member

This hasn't been removed, but should be reviewed.

@vsmenon
Copy link
Member

vsmenon commented Oct 23, 2015

Yeah, this was a strong-hint. We've removed that.

In future, we'll have a warning when we can't determine a non-dynamic type.

@Hixie
Copy link
Contributor Author

Hixie commented Oct 23, 2015

Cool. I filed #24712 on the warning I'd like to see.

What SDK version should I be using to see these warnings be gone?

@vsmenon
Copy link
Member

vsmenon commented Oct 24, 2015

Looks like it hasn't pushed out yet. But, regardless, remove --strong-hints get rid of this hint. That flag will disappear.

@jmesserly
Copy link

I believe this has been fixed. (strong hints are not turned on as part of strong-mode.)

@kevmoo kevmoo added P2 A bug or feature request we're likely to work on and removed Priority-Medium labels Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-ux area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

5 participants