-
Notifications
You must be signed in to change notification settings - Fork 171
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
Recursive getter does not throw warning when using pattern matching #4913
Comments
It's not always a mistake to invoke the same getter, of it's not on the same object. Node get last {
return switch (this.next) {
// Notice that while declaring the name getter, I can access it here without warning.
A(last: final last) => last,
_ => null,
};
} Same getter called, but not on the same object. So this issue requires not just figuring out that the same getter is office again, but also determining whether it's definitely, or possibly, on the same object. |
Yea, we might apply this only when using switch for |
So, if you declare a class with a getter, like this:
The
recursive_getters
rule should warn this case, shouldn't it? Pattern matching does allow you to refer to the getter you're declaring (on its declaration scope body). The same occurs when you create a getter through an extension.I fell in this case because of my copilot, when I tried to build it by running the tests, it just crashed with a non-descriptive error, probably because it is like a recursion with no break. It should not be allowed since it always falls in a runtime error.
Obs.: Re-opening it from dart-lang/language#3652.
The text was updated successfully, but these errors were encountered: