-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Dart 3: Analyzer wants const, compiler doesn't like it #51800
Comments
Possibly related: #51567 |
Yes, this behavior is consistent with the status of #51566: Constant |
Is generalized constant == gonna land in the next few days for Dart 3? If not, can the analyzer stop recommending const where it doesn’t work (yet) until generalized constant == lands? |
I don't know how to handle this, when one part of Dart implements the specification, and another is not. |
I also don't know what the right path is here. However, once users are migrating to Dart 3 it's gonna be a very odd (maybe even frustrating) user experience when users are told by one system to make these const only to be yelled at by another system for doing so... |
I added the milestone to #51566 to raise visibility of the need to have it in. |
This seems like a pretty significant user experience issue. |
I'll look into supporting this in the CFE: |
@leafpetersen do we have clarity around what behavior we actually want here? |
CL in the pipeline: https://dart-review.googlesource.com/c/sdk/+/290320 |
The language team decided a while back to use primitive equality for constant expressions of the form |
With the
prefer_const_constructors
lint is turned on, the analyzer complains about the following code when running withsdk: '>=3.0.0-0 <4.0.0'
as pubspec sdk constraints:However, when giving in to that lint and using const, the code doesn't run anymore:
When lowering the sdk constraints to 2.19, the analyzer does not complain that a const constructor should be used here.
The text was updated successfully, but these errors were encountered: