-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestdart-model-analyzer-specIssues with the analyzer's implementation of the language specIssues with the analyzer's implementation of the language speclegacy-area-analyzerUse area-devexp instead.Use area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Description
Consider this example:
class Car {
int price;
Car(this.price);
factory Car.create() {
print(price);
return Car(123);
}
}Here price is non-static class member and can't be accessed from factory constructor. So the analyzer correctly reports an error:
error: Instance members can't be accessed from a factory constructor. (instance_member_access_from_factory)
However if we try to access the member from lambda or inner function
class Car {
int price;
Car(this.price);
factory Car.create() {
[4, 5, 6].where((x) => x == price).forEach(print);
void f() {
print(price);
}
f();
return Car(123);
}
}analyzer won't report any errors.
Though compiler reports the problem correctly
Error: Getter not found: 'price'.
and aborts compiling
Dart SDK version: 2.9.2 (stable) (Wed Aug 26 12:44:28 2020 +0200) on "windows_x64"
Metadata
Metadata
Assignees
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestdart-model-analyzer-specIssues with the analyzer's implementation of the language specIssues with the analyzer's implementation of the language speclegacy-area-analyzerUse area-devexp instead.Use area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)