Skip to content

Commit f419f6b

Browse files
committed
Update SideEffectAnalyzer.java
1 parent d78442a commit f419f6b

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/intermediatelang/optimizer/SideEffectAnalyzer.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,8 @@ private boolean functionHasSideEffects(ImFunction func) {
514514

515515
private boolean hasGlobalSideEffects(Element elem) {
516516
for (ImVar var : directlySetVariables(elem)) {
517-
if (var.isGlobal()) {
517+
// Some optimization passes temporarily detach vars; in that state isGlobal() throws.
518+
if (isAttachedGlobal(var)) {
518519
return true;
519520
}
520521
}
@@ -530,5 +531,10 @@ private boolean hasGlobalSideEffects(Element elem) {
530531
}
531532
return false;
532533
}
534+
535+
private boolean isAttachedGlobal(ImVar var) {
536+
Element parent = var.getParent();
537+
return parent != null && parent.getParent() instanceof ImProg;
538+
}
533539
}
534540
}

0 commit comments

Comments
 (0)