Skip to content

Commit ee1bfb2

Browse files
committed
cellvars and freevars (and thus the closure) need to be sorted
1 parent f32b10b commit ee1bfb2

File tree

1 file changed

+5
-5
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
import java.util.ArrayList;
2929
import java.util.Collection;
3030
import java.util.HashSet;
31-
import java.util.LinkedHashSet;
3231
import java.util.List;
3332
import java.util.Set;
33+
import java.util.TreeSet;
3434

3535
import com.oracle.graal.python.nodes.expression.ExpressionNode;
3636
import com.oracle.graal.python.nodes.function.FunctionDefinitionNode.KwDefaultExpressionNode;
@@ -69,9 +69,9 @@ public enum ScopeKind {
6969
* Symbols which are local variables but are closed over in nested scopes
7070
*/
7171
// variables that are referenced in enclosed contexts
72-
private LinkedHashSet<String> cellVars;
72+
private TreeSet<String> cellVars;
7373
// variables that are referenced from enclosing contexts
74-
private LinkedHashSet<String> freeVars;
74+
private TreeSet<String> freeVars;
7575

7676
/**
7777
* An optional field that stores translated nodes of default argument values.
@@ -174,7 +174,7 @@ public void addCellVar(String identifier) {
174174

175175
public void addCellVar(String identifier, boolean createFrameSlot) {
176176
if (cellVars == null) {
177-
cellVars = new LinkedHashSet<>();
177+
cellVars = new TreeSet<>();
178178
}
179179
cellVars.add(identifier);
180180
if (createFrameSlot) {
@@ -188,7 +188,7 @@ public void addFreeVar(String identifier) {
188188

189189
protected void addFreeVar(String identifier, boolean createFrameSlot) {
190190
if (freeVars == null) {
191-
freeVars = new LinkedHashSet<>();
191+
freeVars = new TreeSet<>();
192192
}
193193
freeVars.add(identifier);
194194
if (createFrameSlot) {

0 commit comments

Comments
 (0)