-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
No complie time error for late field referencing itself #55468
Comments
Also this example : class MyClass { |
An initializer not being self referential is probably a good warning. I can write a successfull program with a self reference, so it's not necessarily a bug, but I can't find up with any reasonable reason for writing a program like that, so giving a warning unconditionally seems appropriate. Marking as analyzer. We can detect self references in constants because we actually evaluate them at compile time. (A "successful" self-referential initializer could be: class Weird {
final int _defaultLevel;
Weird(int defaultLevel) : _defaultLevel = defaultLevel;
late String _levelString = (this._level, this._levelString).$2; // Initialize level if it isn't.
late int _level = (_levelString = _defaultLevel.toString(), _defaultLevel).$2;
} Here the initialil |
Thank you sir for updating the correct title for me :) |
Stack overflow is a runtime error. There are lots of ways to write programs with runtime errors, that the analyzer cannot recognize at compiler time. The analyzer doesn't generally introduce compile time errors, it only reports errors that are specified in the language specification. |
ok sir, thanks for replying to my issue 😊. |
According to the late fields specification
So, the |
Thank you for taking the time to file an issue!
This tracker is for issues related to:
This Issue is in the repository :
Issue :
The Dart analyzer is not detecting errors for initializing fields by late in the declaration with the value of itself, making Stack Overflow condition. so it needs to disallow the fileds to late initialize by themselves.
example code :
void main() {
MyClass myClass = MyClass();
print(myClass.i);
}
class MyClass {
late int i = this.i;
}
The text was updated successfully, but these errors were encountered: