Open bwilkerson opened 3 years ago
There are a couple of similar cases that ought to be fixed at the same time that I'll just record for posterity.
Iterable<int> get digits {
yield* [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
}
and
Iterable<int> get digits async {
yield* [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
}
Given the following code
The analyzer produces three diagnostics:
It would be nice if the analyzer could produce a single diagnostic stating that a yield statement is only valid in a generator function.
I believe that in order to do that the parser would need to recognize that the
yield
is followed by an expression and parse it as a yield statement rather than as an identifier followed by garbage.It would also require the analyzer to treat the function as if it were a generator for the purpose of flow analysis.