Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8292625: jshell crash on "var a = a" #11263

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ public void visitVarDef(JCVariableDecl tree) {
// declaration position to maximal possible value, effectively
// marking the variable as undefined.
initEnv.info.enclVar = v;
attribExpr(tree.init, initEnv, v.type);
tree.init.type = attribExpr(tree.init, initEnv, v.type);
if (tree.isImplicitlyTyped()) {
//fixup local variable type
v.type = chk.checkLocalVarType(tree, tree.init.type, tree.name);
Expand Down
13 changes: 12 additions & 1 deletion test/langtools/jdk/jshell/ToolSimpleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@

/*
* @test
* @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103 8165405 8173073 8173848 8174041 8173916 8174028 8174262 8174797 8177079 8180508 8177466 8172154 8192979 8191842 8198573 8198801 8210596 8210959 8215099 8199623 8236715 8239536 8247456 8246774 8238173
* @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897
* 8167128 8154513 8170015 8170368 8172102 8172103 8165405 8173073 8173848
* 8174041 8173916 8174028 8174262 8174797 8177079 8180508 8177466 8172154
* 8192979 8191842 8198573 8198801 8210596 8210959 8215099 8199623 8236715
* 8239536 8247456 8246774 8238173 8292625
* @summary Simple jshell tool tests
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
Expand Down Expand Up @@ -957,4 +961,11 @@ public void testSwitchStatementExpressionDisambiguation() {
(a) -> assertCommand(a, "i", "i ==> 1")
);
}

@Test
public void testSelfReference() {
test(
(a) -> assertCommandOutputContains(a, "var a = a;", "cannot use 'var' on self-referencing variable")
);
}
}