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

False positive with top_level_function_literal_block #41571

Closed
rrousselGit opened this issue Apr 19, 2020 · 1 comment
Closed

False positive with top_level_function_literal_block #41571

rrousselGit opened this issue Apr 19, 2020 · 1 comment
Assignees
Labels
analyzer-spec Issues with the analyzer's implementation of the language spec area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@rrousselGit
Copy link

rrousselGit commented Apr 19, 2020

Consider the following code:

class Provider<Res> {
  Provider(Res Function() create);
}

// Fine, no warning
final provider = Provider(() => 42);

// Triggers top_level_function_literal_block but correctly inferred as Provider<String>
final otherProvider = Provider(() {
  return 'Hello world';
});

The line otherProvider = Provider(...0 triggers a top_level_function_literal_block (The type of the function literal can't be inferred because the literal has a block as its body) when the inference worked.

Since the inference worked, this shouldn't trigger the warning.

@devoncarew devoncarew added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Apr 21, 2020
@srawlins srawlins added the analyzer-spec Issues with the analyzer's implementation of the language spec label Jun 16, 2020
@srawlins srawlins added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Apr 28, 2021
@scheglov scheglov self-assigned this May 9, 2021
@scheglov
Copy link
Contributor

scheglov commented May 9, 2021

With https://dart-review.googlesource.com/c/sdk/+/198920 we stopped reporting StrongModeCode.
We have been doing inference with block bodied function expressions for some time, since summary2.

@scheglov scheglov closed this as completed May 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-spec Issues with the analyzer's implementation of the language spec area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants