Browse Source

Improved variable scope lookup for loop statement. Fixes #401.

woollybah 6 years ago
parent
commit
389a02d4f7
1 changed files with 4 additions and 0 deletions
  1. 4 0
      stmt.bmx

+ 4 - 0
stmt.bmx

@@ -635,7 +635,11 @@ Type TForStmt Extends TLoopStmt
 		Local updateCastTypes:Int
 		If TAssignStmt(init) And TIdentExpr(TAssignStmt(init).lhs) Then
 			updateCastTypes = True
+		Else
+			' semant right-hand side first, in case the loop variable is shadowing one from rhs
+			TBinaryCompareExpr(expr).rhs = TBinaryCompareExpr(expr).rhs.Semant()
 		End If
+
 		init.Semant
 
 		If updateCastTypes Then