Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Offen
#990 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
65/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
go
Bereich
backend

Rechercherichtung

The issue is about the 'in' operator not respecting struct field tags. Start by examining the parser and evaluator for the 'in' operator, likely in the 'parser' and 'eval' packages. Look at how struct field access is resolved, comparing the handling of field names vs. 'expr' tags. The provided playground link shows the exact test case; run the tests in the repository to see existing behavior and add a test for this bug. Check for similar issues around struct field tag handling to understand the codebase patterns.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
Go
Sterne
8k
Forks
529
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus expr-lang/expr

Alle Issues in expr-lang/expr

Ähnliche Issues

Weitere Issues zu Go

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.