This is an automated email from the ASF dual-hosted git repository. joshtynjala pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
commit c99f2d12fee450e52fdca4cdc9682feb2d279bfc Author: Josh Tynjala <[email protected]> AuthorDate: Tue Sep 17 13:12:30 2024 -0700 SemanticUtils: isUnprotectedAssignmentInConditional() should return true for any else ifs that have assignment within conditionals too --- .../royale/compiler/internal/semantics/SemanticUtils.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/SemanticUtils.java b/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/SemanticUtils.java index 23d3a6bfc..71ef9d4c7 100644 --- a/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/SemanticUtils.java +++ b/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/SemanticUtils.java @@ -3082,7 +3082,7 @@ public class SemanticUtils case ContainerID: case ConditionalID: current = parent; - parent = current.getParent(); + parent = current.getParent(); break; case WhileLoopID: @@ -3092,7 +3092,18 @@ public class SemanticUtils return current == getNthChild(parent,1); case IfStatementID: - return current == getNthChild(parent,0); + for (int i = 0; i < parent.getChildCount(); i++) + { + // conditions for the first if and all following else + // ifs are added as children of the same parentm + // so we need to check all children, and not just the + // first one, like we do with while + if (parent.getChild(i) == current) + { + return true; + } + } + return false; default: return false;
