Yield _ is not recognized as a valid code by javac

Remi Forax forax at univ-mlv.fr
Thu Oct 10 08:06:33 UTC 2024


Opps, i click submit too fast, an issue was open (https://bugs.openjdk.org/browse/JDK-8335136)
but it has been closed without me understanding why.

Rémi

----- Original Message -----
> From: "Remi Forax" <forax at univ-mlv.fr>
> To: "amber-dev" <amber-dev at openjdk.org>
> Sent: Thursday, October 10, 2024 9:58:22 AM
> Subject: Yield _ is not recognized as a valid code by javac

> Hello,
> It seems javac grammar does not allow yield to be follow by an '_'.
> 
> void main(String[] args) {
>  Consumer<String> value = switch (args[0]) {
>    case "foo" -> {
>      yield _ -> {};
>    }
>    default -> throw new AssertionError();
>  };
> }
> 
> Both ecj and the front compiler of IntelliJ as no trouble with this code,
> it seems to be just a javac bug.
> 
> regards,
> Rémi


More information about the amber-dev mailing list