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. --- interp/interpreter_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'interp') diff --git a/interp/interpreter_test.go b/interp/interpreter_test.go index e6274a4..4e8721a 100644 --- a/interp/interpreter_test.go +++ b/interp/interpreter_test.go @@ -72,13 +72,13 @@ func TestExpr(t *testing.T) { func TestAssign(t *testing.T) { run(t, []etest{ - {src: "var a int = 1; a", res: "1"}, // #00 - {src: "var a, b int = 1, 2; b", res: "2"}, // #01 - {src: "var a, b int; a, b = 1, 2; b", res: "2"}, // #02 - {src: "a, b := 1, 2; b", res: "2"}, // #03 - {src: "func f() int {return 2}; a := f(); a", res: "2"}, // #04 - // {src: "func f() (int, int) {return 2, 3}; a, b := f(), b", res: "3"}, // #05 - // {src: "func f() (int, int) {return 2, 3}; var a, b = f(), b", res: "3"}, // #06 + {src: "var a int = 1; a", res: "1"}, // #00 + {src: "var a, b int = 1, 2; b", res: "2"}, // #01 + {src: "var a, b int; a, b = 1, 2; b", res: "2"}, // #02 + {src: "a, b := 1, 2; b", res: "2"}, // #03 + {src: "func f() int {return 2}; a := f(); a", res: "2"}, // #04 + {src: "func f() (int, int) {return 2, 3}; a, b := f(); b", res: "3"}, // #05 + // {src: "func f() (int, int) {return 2, 3}; var a, b = f(); b", res: "3"}, // #06 }) } -- cgit v1.2.3