Skip to content

Commit ce75021

Browse files
committed
make sure we always have some scope in single input
1 parent 5fcfbb5 commit ce75021

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/ScopeTranslator.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,15 @@ public T visitFile_input(Python3Parser.File_inputContext ctx) {
7676

7777
@Override
7878
public T visitSingle_input(Single_inputContext ctx) {
79-
if (interactive) {
80-
ctx.scope = environment.pushScope(ctx, ScopeInfo.ScopeKind.Module);
81-
} else if (curInlineLocals != null) {
79+
if (!interactive && curInlineLocals != null) {
8280
ctx.scope = environment.pushScope(ctx, ScopeInfo.ScopeKind.Function, curInlineLocals);
81+
} else {
82+
ctx.scope = environment.pushScope(ctx, ScopeInfo.ScopeKind.Module);
8383
}
8484
try {
8585
return super.visitSingle_input(ctx);
8686
} finally {
87-
if (interactive || curInlineLocals != null) {
88-
environment.popScope();
89-
}
87+
environment.popScope();
9088
}
9189
}
9290

0 commit comments

Comments
 (0)