Assignment now checks the type of the operand against the assignee

This commit is contained in:
Mattia Giambirtone 2022-11-23 09:43:22 +01:00
parent b589f8109a
commit ab30d0d891
1 changed files with 1 additions and 0 deletions

View File

@ -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)
if not r.isClosedOver:
self.emitByte(StoreVar, node.token.line)