From 20731d969ebb7e2caa7b9b872f6128cc819cbb05 Mon Sep 17 00:00:00 2001 From: Antoine Viallon Date: Tue, 23 May 2023 23:11:05 +0200 Subject: [PATCH] nodes: fix some issues in Blocks (regarding purity consideration for IR) No longer special case the last node in a Block. Call super() semantic analysis for variables. This may prevent some future issues. --- compiler/nodes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/nodes.py b/compiler/nodes.py index eaf3d64..115afc0 100644 --- a/compiler/nodes.py +++ b/compiler/nodes.py @@ -286,10 +286,9 @@ class Block(Statement): def intermediate_representation(self) -> list[ir.IRItem]: result: list[ir.IRItem] = [] - for node in self.nodes[:-1]: + for node in self.nodes: if not node.pure: result += node.intermediate_representation() - result += self.nodes[-1].intermediate_representation() return result def semantic_analysis(self, context: semantic.Context | None): @@ -316,6 +315,7 @@ class Variable(Node): return [self.identifier] def semantic_analysis(self, context: semantic.Context): + super(Variable, self).semantic_analysis(context) variable = context.get_variable(self.identifier.value) if variable is None: raise SemanticAnalysisError(location=self.location(), message=f"Unknown variable '{self.identifier.value}'")