-
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
Type inference should always infer the return type of operator []= as void #31779
Comments
Lasse and I agreed when we talked about this earlier today: Yes, the inferred return type should be |
The CL has now been landed. |
… void. R=brianwilkerson@google.com, paulberry@google.com Bug: #31779 Change-Id: I1c396cce3f148585218e02ff4e41bc2f85cc924a #31638 Reviewed-on: https://dart-review.googlesource.com/32687 Reviewed-by: Paul Berry <paulberry@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
SGTM. |
This issue affects package yaml when compiling with the common front end. |
The analyzer was fixed in bb52d1a. This CL should fix the front end: https://dart-review.googlesource.com/#/c/sdk/+/35005 |
This still does not work if operator []=(int index, value) {
throw new UnsupportedError("Cannot modify an unmodifiable List.");
} (code from package |
@mraleph It turns out that your case wasn't broken because of the |
For this code:
The front end reports the following error:
As discussed in #31756, it would be better to simply infer a return type of
void
, since returning a value fromoperator []=
is meaningless anyhow. Although this is a small corner case, addressing it seems like it would make the language more consistent, since it would make the type inference rule for the return type ofoperator []=
the same as the type inference rule for the return type of a setter.@leafpetersen and @lrhn do you agree? This would require changes to the front end, the analyzer, and the language spec. I'm happy to do the front end and analyzer changes.
The text was updated successfully, but these errors were encountered: