Integer range patterns ending at 2147483647 generate incorrect JavaScript
Maintainer thường phản hồi trong vòng 1 ngày
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
- 70/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, ocaml
- Lĩnh vực
- compilers
Hướng nghiên cứu
Use the maintenance/12.x compiler with the supplied ReScript switch, first inspecting the generated JavaScript for the integer-range condition. Reproduce the boundary cases and compare the compiler's handling of the exclusive upper bound with the signed 32-bit limit. Done means the generated check accepts 2147483645–2147483647 and rejects 2147483644, including the other listed switch shapes.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
An integer or-pattern ending at 2147483647 (the maximum signed 32-bit integer) compiles to an impossible bound check and rejects values that should match.
Reproduced with the ReScript 12.3.1 compiler on macOS arm64, using the maintenance/12.x code both before and after the change in #8714.
type response = {status: int}
let inRange = (x: response) =>
switch x {
| {status: 2147483645 | 2147483646 | 2147483647} => true
| _ => false
}
Generated JavaScript, identical before and after #8714:
function inRange(x) {
let match = x.status;
if (match >= 2147483645) {
return match < -2147483648;
} else {
return false;
}
}
Expected and observed results:
| Input status | Expected | Actual |
|---|---|---|
| 2147483644 | false | false |
| 2147483645 | true | false |
| 2147483646 | true | false |
| 2147483647 | true | false |
The generated condition requires the same integer to be at least 2147483645 and less than -2147483648, so it can never succeed. This appears to be overflow when converting the exclusive upper bound 2147483647 + 1 into a 32-bit integer literal.
The same failure also reproduces with a plain integer switch, nested records, tuples, variant payloads, arrays, and switches on function-call results.
This was found while reviewing #8714 and is a separate, pre-existing bug: the unsigned-range fix in that PR neither introduces nor fixes it.
- Ngôn ngữ chính
- OCaml
- Star
- 7.5k
- Fork
- 485
- Merge trung bình
- 1 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 65
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
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 rescript-lang/rescript
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
rescript-lang/rescript#8713 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A regex literal that starts a statement is parsed as division, and the formatter removes the parentheses that prevent itCó thể đã có người làm @fhammerschmidt đã nhận 2 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
rescript-lang/rescript#8688 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bsc crashes with `Fatal error: exception Not_found` on `Some(x)` when the type of `x` comes from a transitive dependencyCó thể đã có người làm @fhammerschmidt đã nhận 2 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
rescript-lang/rescript#8687 ·
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
rescript-lang/rescript#8659 · 2 bình luận · 2 reaction ·
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
rescript-lang/rescript#8647 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của rescript-lang/rescript
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
kmmbvnr/rank#196 · 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 74/100
SciML/ModelingToolkit.jl#5255 ·
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 65/100
NVIDIA/cuda-quantum#5539 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
NVIDIA/cuda-python#3015 · 2 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 70/100
ocaml/ocaml#15132 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày