#990·expr

`in` operator on a struct doesn't respect `expr` tags

Author: crazygolemCreated Sep 23, 2026Updated Sep 23, 2026

While the documentation doesn't say that the in operator can be used on structs, it does actually work. However it doesn't respect the expr tag and instead checks membership using the struct's go field names.

Example

With an environment built from:

go
type Outer struct {
	Inner map[string]struct{} `expr:"bar"`
}
type Env struct {
	Outer Outer `expr:"foo"`
}

in operator: "bar" in foo => false "Inner" in foo => true

Field access behaves the opposite: foo.bar => map[] foo.Inner => compilation error

Playground: https://go.dev/play/p/GqjjiidBOx0