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

Bad interaction between prefer_int_literals and Enhanced type inference for generic invocations with function literals #3657

Open
Pante opened this issue Sep 5, 2022 · 1 comment
Labels
false-positive P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@Pante
Copy link

Pante commented Sep 5, 2022

Describe the issue
This issue is related to #2887

At the moment, there's a bad interaction between prefer_int_literals and Enhanced type inference for generic invocations with function literals introduced in 2.18.

The following snippet of code will cause the lint to emit a warning:

final sum = [1.0,  2.0].fold(0.0, (a, b) => a + b); // Triggered by 0.0

However, the code snippet is no longer valid once the suggested fix is applied.

final sum = [1.0,  2.0].fold(0, (a, b) => a + b); // Fails to compile with error: "The return type 'double' isn't a 'int', as required by the closure's context"
@pq
Copy link
Member

pq commented Sep 6, 2022

Thanks for the report!

@bwilkerson bwilkerson added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) P3 A lower priority bug or feature request labels Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false-positive P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants