-
Notifications
You must be signed in to change notification settings - Fork 563
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
Should show warning when trying to modify "const" var #1512
Comments
Thanks for filing an issue! Running this code in my browser is producing this error:
Is that different from what you have been seeing? |
Hi! At DartPad, I was not able to see any error message. Perhaps it was my browser, although I was using a Chromium based one. |
With respect to proposals for language support for statically known immutability, you could take a look at dart-lang/language#125 and dart-lang/language#314. We don't have that, yet. For now it is a purely dynamic property that some collections are unmodifiable. This includes the ones that are obtained by evaluating a constant expression, as in your example. So that's the reason why you do not get an error/warning at compile time for I'll close this issue: Dartpad behaves as expected, and getting a compile-time error message rather than a run-time exception is a request for a language enhancement which should be discussed in the issues in the language repository like the ones mentioned above. |
@jaxlogan can you specify which chromium based browser? Chrome works as intended. Is it Brave perchance? We've had issues with that browser before. |
Without additional information we're not able to resolve this issue, so it will be closed at this time. You're still free to add more info and respond to any questions above, though. We'll reopen the case if you do. Thanks for your contribution! |
DartPad should show some kind of warning/error when trying to mutate a "const" declared value, such as:
The text was updated successfully, but these errors were encountered: