Skip to content

Commit 91e116e

Browse files
committed
track nonlocals vars as cells
1 parent bf5b153 commit 91e116e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,11 @@ public T visitGlobal_stmt(Python3Parser.Global_stmtContext ctx) {
225225
@Override
226226
public T visitNonlocal_stmt(Python3Parser.Nonlocal_stmtContext ctx) {
227227
for (TerminalNode name : ctx.NAME()) {
228-
environment.addNonlocal(name.getText());
228+
String identifier = name.getText();
229+
environment.addNonlocal(identifier);
230+
if (trackCells) {
231+
environment.registerCellVariable(identifier);
232+
}
229233
}
230234
return super.visitNonlocal_stmt(ctx);
231235
}

0 commit comments

Comments
 (0)