-
Couldn't load subscription status.
- Fork 1.7k
Description
The analyzer currently (ac9b6d1) does not report a compile-time error for the following program, in spite of the fact that augmented() is specified to have type void:
class A {
A x;
A() {
print('Running introductory!');
}
augment A(): x = augmented();
}Also, the expression augmented() should evaluate to null, which means that it would be a soundness violation to allow it to be used as the initial value of x.
Another program which is accepted by the analyzer with no compile-time errors is the following:
class A {
dynamic x;
A() {
print('Running introductory!');
}
augment A(): x = augmented();
}In this case I believe there must also be an error (this is discussed in dart-lang/language#4039), even though the above mentioned soundness violation does not exist.
A similar situation exists with a redirecting generative constructor where this(augmented()) does not cause any compile-time errors.
class B {
B(Object? o);
B.named(): this(42);
augment B.named(): this(augmented());
}In this case there should be an error because an expression of type void (namely augmented()) occurs in a location where an Object? is expected, and it is not on the allowlist for using the value of an expression of type void.