CFE: Accept normal completion in function literal => nullable return type #42743
Labels
legacy-area-front-end
Legacy: Use area-dart-model instead.
NNBD
Issues related to NNBD Release
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
Cf. #42568, dart-lang/language#1063:
The following program gives rise to a compile-time error in
dart
(commit bbe8c55), but is accepted bydartanalyzer
(same commit):The program should be accepted, because function literal return type inference treats normal completion of the body is an indication that null may be returned (so it is just as good as
return null;
).Consequently, the inferred return type of the above function literal will be
int?
, and it is then not an error to reach the end of the function body.@johnniwinther, I'm surprised that I couldn't find an existing issue on this, so forgive me if this is a duplicate.
The text was updated successfully, but these errors were encountered: