`in` operator on a struct doesn't respect `expr` tags
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Go
- Star
- 8k
- Fork
- 529
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của expr-lang/expr
-
docs needed
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 62/100
-
`find`, `findIndex`, `first` and `get` are type-checked as the element type where they return nil Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
-
Release latest master branch Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
Tất cả issue của expr-lang/expr
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
bazel-contrib/rules_go#4726 · 1 bình luận ·
-
area/auto-scaling area/monitoring area/ops-productivity kind/enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Type/Improvement
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 90/100
OpenNSW/nsw-srilanka#522 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100