From 60f6ebc8d8369721e105d826145af2b8856ac67e Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Tue, 27 Jan 2026 16:37:02 +0100 Subject: fix: improve multiple define The VM Vassign instruction now takes an argument to indicates the number of assignations to perform on the stack. Definitions with a function returning multiple values now work. There is still some simplifications, and also to apply the same strategy to var declarations with assign. --- vm/vm.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'vm/vm.go') diff --git a/vm/vm.go b/vm/vm.go index f5bb78e..96d61eb 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -311,8 +311,13 @@ func (m *Machine) Run() (err error) { mem[sp-3].SetMapIndex(mem[sp-2].Value, mem[sp-1].Value) mem = mem[:sp-2] case Vassign: - mem[sp-2].Set(mem[sp-1].Value) - mem = mem[:sp-2] + n := c.Arg[0] + for i := 0; i < n; i++ { + mem[sp-n-i-1].Set(mem[sp-n+i].Value) + } + mem = mem[:sp-n-1] + // mem[sp-2].Set(mem[sp-1].Value) + // mem = mem[:sp-2] } ip++ } -- cgit v1.2.3