count() without a predicate compiles for non-bool arrays and fails at run time
Maintainer thường phản hồi trong vòng 1 ngày
@minilan677-netizen đang làm issue này rồi.
Từ ngày 26/11/2026.
- #1032 của @minilan677-netizen — đang mở
Đá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
- 25/100
Hướng nghiên cứu
Start by tracing how the checker handles count() without a predicate and compare it with the predicate form, which already rejects non-boolean results. Check how known element types differ from unknown types such as []any; the issue names no source files or tests. Done means known non-bool element types fail at compile time while bool and unknown element types still compile.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
count() without a predicate counts the true elements of an array (count([true, false, true]) == 2). The checker doesn't look at the element type in that form, though. So an array whose element type is known and isn't bool compiles fine, then fails at run time on the VM's bool assertion:
env := map[string]any{"ints": []int{1, 2, 3}}
program, err := expr.Compile(`count(ints)`, expr.Env(env)) // err == nil
_, err = expr.Run(program, env)
// interface conversion: interface {} is int, not bool (1:1)
The same thing happens with count(1..3), count(filter(ints, # > 1)), count(map(ints, #)), and arrays of strings, structs or *bool.
The predicate form already rejects this at compile time:
count(ArrayOfInt, {#})
predicate should return boolean (got int) (1:19)
Expected: count(ints) gives a similar compile-time error. Arrays of bool, and arrays whose element type is unknown ([]any, untyped env), should keep compiling as they do now.
Checked on master (c4b0946) with Go 1.27.3.
- Ngôn ngữ chính
- Go
- Star
- 8.1k
- Fork
- 544
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 25
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
expr-lang/expr#1037 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 57/100
Maintainer thường phản hồi trong vòng 1 ngày
-
OSS-Fuzz issue 578739164Đang mởwontfix
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 35/100
expr-lang/expr#995 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`find`, `findIndex`, `first` and `get` are type-checked as the element type where they return nilCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
expr-lang/expr#989 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
expr-lang/expr#975 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của expr-lang/expr
Issue tương tự
-
Provider Key: Sauberr/neckrezĐang mởprovider-key submission
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
opentofu/registry#6740 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
nightgauge/nightgauge#3713 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
fix: restore GitHub issue templates and check their license headersCó thể đã có người làm @slievrly đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày