Gigih Aji Ibrahim avatar Gigih Aji Ibrahim committed b8b37e4

ForStmt now support Array and Map

Comments (0)

Files changed (1)

src/step/typechecker.py

 
         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 )
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.