From daeb7018ca8a60c58f2acec71e8a9439588fbbf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dobranowski?= Date: Mon, 16 Dec 2024 14:56:33 +0100 Subject: [PATCH] Fix Int value in semantic analyser --- semantic_analyser.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/semantic_analyser.py b/semantic_analyser.py index 6d9ac71..a70fdc4 100644 --- a/semantic_analyser.py +++ b/semantic_analyser.py @@ -73,6 +73,8 @@ def visitSimpleAssignment(self, ctx: MyParser.SimpleAssignmentContext): if ctx.id_(): # a = 1 variable = ctx.id_().getText() new_type = self.visit(ctx.expression()) + if isinstance(new_type, Int): + new_type.value = None if self.memory_stack.get(variable) is None or ( same_type(self.memory_stack.get(variable), new_type) ): @@ -84,6 +86,8 @@ def visitSimpleAssignment(self, ctx: MyParser.SimpleAssignmentContext): else: ## a[0] = 1 reference = self.visit(ctx.elementReference()) new_type = self.visit(ctx.expression()) + if isinstance(new_type, Int): + new_type.value = None if not same_type(reference, new_type): ctx.parser.notifyErrorListeners( "Incompatible types in an assignment", ctx.getChild(1).getSymbol()