Continue in switch
Brian Goetz
brian.goetz at oracle.com
Tue May 8 21:21:13 UTC 2018
Yes, that's what I'm aiming at. If you have something simple where the
switch is not enclosed in a loop, then bare "continue" does the obvious
thing; if there is an ambiguity, you have to say "continue label" or
"continue switch". Hence the warning now for when that might happen later.
On 5/8/2018 4:31 PM, John Rose wrote:
>
> Brian, are you thinking that bare continue, inside switch, *inside loop*,
> is an *ambiguity error*? That would be worth warning about about:
> Today's correct code would become an error tomorrow:
>
> for (;;) {
> switch (x) {
> case 0:
> continue; // Error/warning: ambiguous unlabeled continue
> }
> }
>
> The message could say "unlabeled continue is ambiguous when
> nested in both switch and proper loop, repair by saying either
> 'continue switch' or 'continue for', or use a label."
>
> In that case, the warnings could be sent even after feature adoption.
> Eventually when the warnings turn to errors, no code changes
> semantics, but some code breaks. Or make it be a warning forever.
More information about the amber-spec-experts
mailing list