RFR: 8334722: Error emitted when switch expression does not yield any value lacks reasoning [v2]
Evemose
duke at openjdk.org
Sat Jun 22 23:37:20 UTC 2024
> Please review this trivial enhancement to informativity of error emiited when switch expression does not yield value in any branch lacks reasoning.
>
> Issue body:
> Currently, when switch expression does not yield any value, compiler emits following error: "switch expression does not have any result expressions". While this gives information on how to solve the issue, the exact reason of this error stays unclear, expecially because switch *statements* do not have same requirement. Recently, there even were question about this in one of jdk mailing lists.
>
> The source of issue becomes obvious if we look where this error is reported: it is emmited in Attr class when javac is unable to assign type to switch expression. Therefore, I propose to change the emitted error text to following: "Unable to determine switch expression type: no branch that yield value found".
>
> If anyone have ideas on how to furthernore improve this error message, please feel free to share.
Evemose has updated the pull request incrementally with one additional commit since the last revision:
fix typo
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/19837/files
- new: https://git.openjdk.org/jdk/pull/19837/files/ee99d16e..27b3c09b
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=19837&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=19837&range=00-01
Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/19837.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/19837/head:pull/19837
PR: https://git.openjdk.org/jdk/pull/19837
More information about the compiler-dev
mailing list