-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[Analyzer] evaluation of const expression fails when List.length
is used in assertion
#37503
Comments
Removing the assertion on |
List.length
is used in assertion
Looks like this wouldn't compile in dart2js either... At least for dartpad, it complains that the value isn't a string. |
|
You cannot get the length of a list in a constant expression. The language specification says so here:
So it must be rejected at compile-time. This is one of many situations where it's tempting to make Dart constant expressions just a little bit more expressive, but it is quite costly (in so many ways) so it's not very likely to happen. One issue is that you can write a |
In my example, isn't the |
Ahh I see, if I did it for some other arbitrary type it would fail. So is the bug that the VM compiler allows this? |
I believe the bug here is that the front-end is not rejecting this at compile time. |
Here's the existing bug: Closing this in favor of that. |
As far as I can tell this should just work (it works at runtime in the VM), but it's failing the analyzer.
/cc @stereotype441 @pq
The text was updated successfully, but these errors were encountered: