1. Gigih Aji Ibrahim
  2. pytegal


Gigih Aji Ibrahim  committed b8b37e4

ForStmt now support Array and Map

  • Participants
  • Parent commits 6f9dd7d
  • Branches default

Comments (0)

Files changed (1)

File src/step/typechecker.py

View file
         node.expr = self.visit(node.expr)
-        if not isA(node.expr.type, RangeType, ListType, DictType):
+        if not isA(node.expr.type, RangeType, ListType, DictType, ArrayType, MapType):
             raise SemanticError(node.loc, "ForStmt need type 'Range', 'List', or 'Dict' but got {} instead".format(node.expr.type))
         ## mode 'in' only need one var, mode 'of' need two and only supported by Dict
         for i in node.vars:
             if node.expr.type == RangeType.instance():
                 symbol = Var(node, i, self.tt.IntType())
-            elif isA(node.expr.type, ListType, DictType):
+            elif isA(node.expr.type, ListType, DictType, ArrayType, MapType):
                 symbol = Var(node, i, node.expr.type.typeArgs[0])
             symbol.local = True
             report.info("\tvClosureExpr():: target type in CallExpr = {}".format(targetType))
             node.returnType = targetReturnType
+        ### otherwise
+        else:
+            raise SemanticError("\tvClosureExpr():: FIXME: closureExpr inside implicit return statement is not supported")
         node.symbol = Def( None, '<closure>', node.returnType, node.stmts )