Yield _ is not recognized as a valid code by javac

Remi Forax forax at univ-mlv.fr
Thu Oct 10 07:58:22 UTC 2024


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