diff options
| author | Marc Vertes <mvertes@free.fr> | 2026-01-27 16:37:02 +0100 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2026-01-27 16:37:02 +0100 |
| commit | 60f6ebc8d8369721e105d826145af2b8856ac67e (patch) | |
| tree | 002073b75edc68aba95399db89f50b24ebb6935f /interp | |
| parent | aa5861917ac2543f85bf4cfefbb69cf501d4de41 (diff) | |
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.
Diffstat (limited to 'interp')
| -rw-r--r-- | interp/interpreter_test.go | 14 |
1 files changed, 7 insertions, 7 deletions
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 }) } |
