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

Inconsistent type inference behavior of block-type vs expression-type closures #29606

Closed
stereotype441 opened this issue May 12, 2017 · 5 comments
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). language-strong-mode-polish P2 A bug or feature request we're likely to work on

Comments

@stereotype441
Copy link
Member

Consider the following code:

typedef num FunctionReturningNum();

main() {
  Object o = 1;
  FunctionReturningNum a = () => o;
  FunctionReturningNum b = () { return o; }
}

Type inference currently infers a return type of Object for the closure in a, and a return type of num for the closure in b.

The behavior of expression-type closures should be changed to match that of block-type closures.

@stereotype441 stereotype441 added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. legacy-area-front-end Legacy: Use area-dart-model instead. area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels May 12, 2017
@bwilkerson bwilkerson added the P2 A bug or feature request we're likely to work on label May 30, 2017
@jensjoha
Copy link
Contributor

jensjoha commented Jan 5, 2018

This no longer seem to be the case. @stereotype441 can we close?

@stereotype441
Copy link
Member Author

This issue was fixed in the front end in b755025. But this bug is about the analyzer. Since the analyzer hasn't yet been migrated to the front end, I am planning to replicate this bug fix in the analyzer. So I would like to leave this bug open until then.

@stereotype441 stereotype441 self-assigned this Jan 5, 2018
@stereotype441 stereotype441 removed the legacy-area-front-end Legacy: Use area-dart-model instead. label Jan 5, 2018
@jensjoha
Copy link
Contributor

jensjoha commented Jan 5, 2018

OK, thanks for clearing that up.

@leafpetersen
Copy link
Member

@stereotype441 The example above no longer reproduces on bleeding edge. Should we close this?

@stereotype441
Copy link
Member Author

Confirmed that this has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). language-strong-mode-polish P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

4 participants