From 3d64f909cfb55d8886ac4b4839a98f8f6cdc98e7 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Tue, 2 Dec 2025 15:45:14 +0100 Subject: feat: support of struct literal composite Added missing vm instructions to allocate a typed value on the stack and to set a structure field. It's possible now to generate struct literal composites for non keyed struct fields. --- interp/interpreter_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'interp/interpreter_test.go') diff --git a/interp/interpreter_test.go b/interp/interpreter_test.go index 21e6274..42cb7e2 100644 --- a/interp/interpreter_test.go +++ b/interp/interpreter_test.go @@ -258,6 +258,7 @@ func TestComposite(t *testing.T) { run(t, []etest{ {src: "type T struct{}; t := T{}; t", res: "{}"}, {src: "t := struct{}{}; t", res: "{}"}, - // {src: `type T struct{N int; S string}; t := T{2, "foo"}`, res: `{2 foo}`}, + {src: `type T struct {}; var t T; t = T{}; t`, res: "{}"}, + {src: `type T struct{N int; S string}; var t T; t = T{2, "foo"}; t`, res: `{2 foo}`}, }) } -- cgit v1.2.3