-
Notifications
You must be signed in to change notification settings - Fork 225
Closed
Labels
questionFurther information is requestedFurther information is requestedwildcard-variablesThe wildcard-variables featureThe wildcard-variables feature
Description
We could make it an error, or we could lint it, but an initializing expression in a late
variable declaration should presumably be recognized as dead code if the variable is wildcarded (that is, it is local and has the name _
):
int f() {
print('Work really hard on finding that int!');
return 42; // got'yer
}
void main() {
late int _ = f();
late final int _ = f();
// ... no matter what, we will not find that int ...
}
Similarly, a wildcarded late
variable with no initializing expression can not be evaluated, and it can not have a new value assigned. So the variable itself would be "dead memory". Error? Lint? OK?
void main() {
late int _;
late final int _;
// ... that memory is wasted ...
}
Perhaps we should just say that it is an error for a late
variable to be wildcarded.
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requestedwildcard-variablesThe wildcard-variables featureThe wildcard-variables feature