RFR: 8301580: Error recovery does not clear returnResult [v2]
Jan Lahoda
jlahoda at openjdk.org
Fri Feb 3 19:08:25 UTC 2023
> Considering code like:
>
> class C {
> void m
> {
> return;
> }
> }
>
>
> `void m` is wrapped in an erroneous tree (which is good), and if/when `Attr` is processing it in `visitErroneous`, it will create a new `Env` to attribute the erroneous part.
>
> But, `Attr` will set a `returnResult` into the `Env`'s info - and that info is shared with the outter `Env`, so there will be a `returnResult` set after `visitErroneous`. `{ return ; }` is interpreted as an initializer, and there should be an error for the `return` there, but this error is missing, due to the set `returnResult`. This will then fail later in `Flow` with an exception:
>
>
> $ javac -XDshould-stop.at=FLOW -XDdev /tmp/C.java
Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision:
Using info.dup(), as suggested.
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/12361/files
- new: https://git.openjdk.org/jdk/pull/12361/files/4acb0d43..06a70c81
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=12361&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=12361&range=00-01
Stats: 9 lines in 1 file changed: 0 ins; 5 del; 4 mod
Patch: https://git.openjdk.org/jdk/pull/12361.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/12361/head:pull/12361
PR: https://git.openjdk.org/jdk/pull/12361
More information about the compiler-dev
mailing list