Skip to content

in operator on a struct doesn't respect expr tags #990

Description

@crazygolem

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:

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions