Skip to content

Commit 4d6bc4e

Browse files
authored
Fix Int value in semantic analyser (#13)
1 parent 757a58b commit 4d6bc4e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

semantic_analyser.py

+4
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ def visitSimpleAssignment(self, ctx: MyParser.SimpleAssignmentContext):
7373
if ctx.id_(): # a = 1
7474
variable = ctx.id_().getText()
7575
new_type = self.visit(ctx.expression())
76+
if isinstance(new_type, Int):
77+
new_type.value = None
7678
if self.memory_stack.get(variable) is None or (
7779
same_type(self.memory_stack.get(variable), new_type)
7880
):
@@ -84,6 +86,8 @@ def visitSimpleAssignment(self, ctx: MyParser.SimpleAssignmentContext):
8486
else: ## a[0] = 1
8587
reference = self.visit(ctx.elementReference())
8688
new_type = self.visit(ctx.expression())
89+
if isinstance(new_type, Int):
90+
new_type.value = None
8791
if not same_type(reference, new_type):
8892
ctx.parser.notifyErrorListeners(
8993
"Incompatible types in an assignment", ctx.getChild(1).getSymbol()

0 commit comments

Comments
 (0)