-
Notifications
You must be signed in to change notification settings - Fork 1.7k
analyzer should warn about final super parameters #48699
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
Comments
/cc @pq |
Why? Is it specified somewhere? And the super-formal parameters specification also mentions But in the language specification I see And this code works fine in VM. class A {
final int value;
A(final this.value);
}
void f(final int value) {}
main() {} So, I don't see why it should not work for |
A super parameter is already final, so |
We could definitely consider linting or hinting for this. My preference would be to make it a hint I guess but maybe I'm missing a reason someone might value this redundancy? |
If final is allowed there, why does it give a runtime error? Should that error be removed then as well? |
Yes, it's a bug that you got a runtime error. It's effectively dead code, so a hint seems reasonable to me. |
Wouldn't that be a compile-time error from the vm, rather than an actual run time error? If this is true then it should be reported as an issue on the common front end. |
I understood there is a new issue to be created for the I am also under the impression that this should also be applied to Please look into https://dart-review.googlesource.com/c/sdk/+/239640 |
Perhaps the error message from the CFE was emitted by some earlier version? I don't see it with the current CFE, not for a formal of the form |
Or possibly triggered in the last few days in the SDK. It is reproducible with:
|
Right, I do get the error, with a bleeding edge |
The analyzer doesn't think anything is wrong with this code, but when I execute it, I get the following error:
The analyzer should tell me about this problem while I write the code so I can correct it before running my program.
(This was discovered while debugging #48698)
The text was updated successfully, but these errors were encountered: