Assignment now checks the type of the operand against the assignee
This commit is contained in:
parent
b589f8109a
commit
ab30d0d891
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue