Skip to content
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

It should be a warning when operator [] and operator []= don't have compatible types #15175

Open
peter-ahe-google opened this issue Nov 19, 2013 · 2 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@peter-ahe-google
Copy link
Contributor

According to dangling.feet on misc@, this doesn't cause a warning:

class M<T> {
  void operator[]=(String key, int value) {
  }

  String operator[](int i) {
  }
}

Perhaps it should.

@gbracha
Copy link
Contributor

gbracha commented Aug 23, 2014

One can argue for this, but I think it is possible to have too many rules and special cases.


Set owner to @gbracha.
Added Accepted label.

@peter-ahe-google peter-ahe-google added Type-Defect area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Aug 23, 2014
@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed priority-unassigned labels Feb 29, 2016
@lrhn
Copy link
Member

lrhn commented Jan 12, 2024

We have rules that constrain the types of a getter and setter pair. (Maybe we shouldn't, but we currently do.)
We generally treat [] as a getter and []= as a setter, so it would make sense to give them similar constraints. Or remove them from getters and setters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants