diff --git a/ExprPrimaryNodes.py b/ExprPrimaryNodes.py index eb236687e54fc074316800ee2976f82d352ace06..7f035493eca83fa54cc2417438e0cc1ee9a7f508 100644 --- a/ExprPrimaryNodes.py +++ b/ExprPrimaryNodes.py @@ -135,11 +135,13 @@ class ArrayAccessNode(ASTNode): def disambigName(self): self.array.disambigName() self.index.disambigName() - # helperDisambigName(self.array) - # helperDisambigName(self.index) + def checkType(self): + self.array.disambigName() # hacky fix, not sure why disambigName wasn't called before self.array.checkType() self.index.checkType() + if not self.array.myType.isArray: + raise Exception("ERROR: Cannot perform array access on non-array {}".format(self.array.name)) if not self.index.myType.isNum(): raise Exception("ERROR: Array index must be a number.") self.myType = TypeStruct(self.array.myType.name, self.array.myType.typePointer) @@ -410,7 +412,7 @@ class FieldAccessNode(ASTNode): self.children.append(self.primary) self.children.append(self.ID) - def disambigName(self): + def disambigName(self): if not self.primary: # this implies that the ID has nothing that comes before it # helperDisambigName(self.ID) self.ID.disambigName()