Open modulovalue opened 1 year ago
Great catch! It's interesting that this is legal but 🤷 in that case we should not let it influence the inferred types.
@stereotype441
To add some context, this occurs regardless of where the return statement is placed.
I believe this is a more representative use case than returning at the very end, which yields (pun intended) the same errantly inferred nullable type:
final conditionEmitter = () async* {
if (hasConditionA) {
yield true;
return;
}
if (hasConditionB) {
yield false;
return;
}
yield* _innerConditionEmitter;
};
Consider the following:
I think that the return statement does not contribute to the output of the generator and that it shouldn't have any effect on the type of foo.
However, this fails analysis with:
but compilation succeeds with the output:
[value]
Reproducible on DartPad