clone
Some checks failed
Build / build (push) Failing after 1m45s
Test / build (push) Failing after 12m0s

This commit is contained in:
Chuck Smith
2024-03-15 15:35:45 -04:00
parent 2988719c9c
commit 80f1a2d78c
6 changed files with 59 additions and 6 deletions

View File

@@ -156,7 +156,12 @@ func (vm *VM) Run() error {
globalIndex := code.ReadUint16(ins[ip+1:])
vm.currentFrame().ip += 2
vm.globals[globalIndex] = vm.pop()
ref := vm.pop()
if mutable, ok := ref.(object.Mutable); ok {
vm.globals[globalIndex] = mutable.Clone()
} else {
vm.globals[globalIndex] = ref
}
case code.OpAssign:
ident := vm.pop()