diff options
| author | Marc Vertes <mvertes@free.fr> | 2025-12-02 15:45:14 +0100 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2025-12-02 15:45:14 +0100 |
| commit | 3d64f909cfb55d8886ac4b4839a98f8f6cdc98e7 (patch) | |
| tree | c0e4149ef652f2d422d2f598da1651fde4009496 /interp | |
| parent | f40a1c23467eef36f53635e525f8b25f591e8a45 (diff) | |
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.
Diffstat (limited to 'interp')
| -rw-r--r-- | interp/interpreter_test.go | 3 |
1 files changed, 2 insertions, 1 deletions
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}`}, }) } |
