RFR: 8292625: jshell crash on "var a = a" [v2]
Bo Zhang
duke at openjdk.org
Mon Nov 21 23:06:50 UTC 2022
On Mon, 21 Nov 2022 14:25:38 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
>> Bo Zhang has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Remove unnecessary space
>
> Good catch, but I would personally prefer if `attribExpr` would set the type (as it does under normal circumstances), presumably here?
>
> https://github.com/openjdk/jdk/blob/5c3345404d850cf01d9629b48015f1783a32bfc0/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java#L4651
>
> Also, might be nice to have a (core javac) test that would not rely on JShell, if possible.
@lahodaj Done moving the assignment. However, this was not a problem with `javac`, probably due to different code path:
# zhb @ zhb in ~/Projects/jdk on git:jdk-8292625 x [7:03:45] C:1
$ cat Test.java
public class Test {
public static void main() {
var a = a;
}
}
# zhb @ zhb in ~/Projects/jdk on git:jdk-8292625 x [7:03:48]
$ /Library/Java/JavaVirtualMachines/temurin-19.jdk/Contents/Home/bin/javac Test.java
Test.java:3: error: cannot infer type for local variable a
var a = a;
^
(cannot use 'var' on self-referencing variable)
1 error
printing javac parameters to: /Users/zhb/Projects/jdk/javac.20221122_070353.args
That's why I put the test into jshell tests.
-------------
PR: https://git.openjdk.org/jdk/pull/11263
More information about the compiler-dev
mailing list