Skip to content

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

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

Open
Pante opened this issue Sep 5, 2022 · 1 comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-linter Issues with the analyzer's support for the linter package linter-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 #58490

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
@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 19, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 19, 2024
@bwilkerson bwilkerson added area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. and removed legacy-area-analyzer Use area-devexp instead. labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-linter Issues with the analyzer's support for the linter package linter-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

4 participants