Sockeye: Fix duplicate variable check for nested for loops
authorDaniel Schwyn <schwyda@student.ethz.ch>
Mon, 31 Jul 2017 16:29:16 +0000 (18:29 +0200)
committerDaniel Schwyn <schwyda@student.ethz.ch>
Mon, 31 Jul 2017 16:29:16 +0000 (18:29 +0200)
Signed-off-by: Daniel Schwyn <schwyda@student.ethz.ch>

tools/sockeye/SockeyeTypeChecker.hs

index 220b54f..540b6a1 100644 (file)
@@ -396,10 +396,10 @@ instance Checkable a b => Checkable (ParseAST.For a) (CheckAST.For b) where
             varRanges = ParseAST.varRanges ast
             varNames = map ParseAST.var varRanges
             body = ParseAST.body ast
-        checkDuplicates (curModule context) DuplicateVariable varNames
+            currentVars = vars context
+        checkDuplicates (curModule context) DuplicateVariable (varNames ++ Set.elems currentVars)
         ranges <- check context varRanges
         let
-            currentVars = vars context
             bodyVars = currentVars `Set.union` (Set.fromList varNames)
             bodyContext = context
                 { vars = bodyVars }