From 90284c5bedc5ab7bb442b34ef470744578dcd266 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 3 Dec 2025 15:28:18 +0100 Subject: feat: support literal struct expressions with keyed elements --- vm/type.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'vm/type.go') diff --git a/vm/type.go b/vm/type.go index 5f91eee..782aa28 100644 --- a/vm/type.go +++ b/vm/type.go @@ -94,3 +94,13 @@ func StructOf(fields []*Type) *Type { } return &Type{Rtype: reflect.StructOf(rf)} } + +// FieldNameIndex returns the index of struct field name. +func (t *Type) FieldNameIndex(name string) []int { + for _, f := range reflect.VisibleFields(t.Rtype) { + if f.Name == name { + return f.Index + } + } + return nil +} -- cgit v1.2.3