augmented()
in generative constructors needs additional compile-time checks
#56477
Labels
analyzer-spec
Issues with the analyzer's implementation of the language spec
area-analyzer
Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
feature-augmentations
Implementation of the augmentations feature
P2
A bug or feature request we're likely to work on
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
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 typevoid
: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 ofx
.Another program which is accepted by the analyzer with no compile-time errors is the following:
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.In this case there should be an error because an expression of type
void
(namelyaugmented()
) occurs in a location where anObject?
is expected, and it is not on the allowlist for using the value of an expression of typevoid
.The text was updated successfully, but these errors were encountered: