From ab30d0d891879564a1090942c631ab4b36bd6a13 Mon Sep 17 00:00:00 2001 From: Mattia Giambirtone Date: Wed, 23 Nov 2022 09:43:22 +0100 Subject: [PATCH] Assignment now checks the type of the operand against the assignee --- src/frontend/compiler.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/src/frontend/compiler.nim b/src/frontend/compiler.nim index 4c9d35e..91252a5 100644 --- a/src/frontend/compiler.nim +++ b/src/frontend/compiler.nim @@ -1828,6 +1828,7 @@ proc assignment(self: Compiler, node: ASTNode) = self.error(&"cannot assign to '{name.token.lexeme}' (value is a constant)", name) elif r.isLet: self.error(&"cannot reassign '{name.token.lexeme}' (value is immutable)", name) + self.check(node.value, r.valueType) self.expression(node.value) if not r.isClosedOver: self.emitByte(StoreVar, node.token.line)