Skip to content

Commit

Permalink
Fix special case, where the list is modified while iterating over it
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadow-Devil committed Jun 12, 2024
1 parent 015f712 commit 67078c8
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,11 @@ public void visit(BLangTestablePackage node, AnalyzerData data) {

private void analyzeTopLevelNodes(BLangPackage pkgNode, AnalyzerData data) {
List<TopLevelNode> topLevelNodes = pkgNode.topLevelNodes;
for (TopLevelNode topLevelNode : topLevelNodes) {
analyzeNode((BLangNode) topLevelNode, data);

// topLevelNodes are modified while iterating over them
// noinspection ForLoopReplaceableByForEach
for (int i = 0; i < topLevelNodes.size(); i++) {
analyzeNode((BLangNode) topLevelNodes.get(i), data);
}
pkgNode.completedPhases.add(CompilerPhase.CODE_ANALYZE);
}
Expand Down

0 comments on commit 67078c8

Please sign in to comment.