Switch on an option of an untagged variant with an `@as(undefined)` case takes the wrong arm for `Some` of that case
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 28/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
Start with rejects_nested_some in compiler/ml/matching.ml, which decides whether a pattern reads the payload with Pval_from_option_not_nest and skips unwrapping the nested Some box. Reproduce with the g(Some(U)) snippet from the issue and inspect the compiled JavaScript for the typeof and === undefined tests. Done when Some(U) reaches the Some(_) arm and prints SU, with the constant and runtime-built cases agreeing.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Found by differential semantic drift analysis from b123b7c3 to c10223e8.
What is broken
@unboxed type t = @as(undefined) U | S(string) | I(int)
let g = (x: option<t>) =>
switch x {
| None => "None"
| Some(S(_)) => "SS"
| Some(I(_)) => "SI"
| Some(_) => "SU"
}
Console.log(g(Some(U)))
Expected SU. At c10223e8 it prints SI; at b123b7c3 it printed None (the construction bug fixed by #9008). A Some(U) built at run time (let h = v => g(Some(v)), h(U)) prints SI at both commits, so the match bug predates the range; #9008 makes constant values reach it too. Matches that name Some(U) explicitly, and tagged variants, are correct.
The compiled g tests x !== undefined, then x === undefined, then typeof x === "string", and otherwise returns "SI", without unwrapping the nested-Some box first: the boxed Some(U) fails the first two tests and lands in the last case.
rejects_nested_some returns true for _ and for untagged payload patterns, so the match reads the payload with Pval_from_option_not_nest, which skips unwrapping.
Possible cause (speculation only)
rejects_nested_some assumes that each pattern rejects the box on its own test, but the untagged dispatch decides the last remaining case by elimination, without a test of its own.
🤖 Generated with Claude Code
- Ngôn ngữ chính
- OCaml
- Star
- 7.5k
- Fork
- 484
- Merge trung bình
- 17 giờ 9 phút
- Pull request đã merge (30 ngày)
- 264
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
- 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
-
Exception analysis does not know the Temporal `fromStringOrThrow` functionsCó thể đã có người làm @cknitt đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
rescript-lang/rescript#9182 ·
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 25/100
rescript-lang/rescript#9233 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
rescript-lang/rescript#9230 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
rescript-lang/rescript#9229 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 44/100
rescript-lang/rescript#9228 ·
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ự
-
A match arm above the largest i64 is compared as 0Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
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
paradigmxyz/solar#2436 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug bulk-filed needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 2 ngày
-
area:codegen backend:slang bug direction:output
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 87/100
gleam-lang/gleam#6491 ·
Maintainer thường phản hồi trong vòng 1 ngày