Compiler crash (matching.ml assertion) on dict and optional-field record patterns mixing a value and `?None` on one key
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
- #8842 của @cknitt — đã merge
Đá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
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, ocaml
- Lĩnh vực
- compilers
Hướng nghiên cứu
Start with compiler/ml/matching.ml at get_args_constr around line 1236, then read compiler/ml/dict_pattern.ml around lines 73–102 to understand how dict keys become optional record labels. Reproduce the crash with the supplied dict and optional record pattern examples, and inspect the existing compiler tests for matching. Done means both examples compile without an assertion failure; pull request #8842 is already open.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Found by adversarial experiments on semantic analysts.
What is broken
This match makes bsc crash:
let f = (d: dict<int>) =>
switch d {
| dict{"x": 1} => 0
| dict{"y": 2} => 0
| dict{"x": ?None} => 1
| _ => 2
}
$ bsc -nopervasives C1.res
Fatal error: exception File "compiler/ml/matching.ml", line 1236, characters 9-15: Assertion failed
Expected: it compiles. The compiler at ece8b148 produces:
function f(d) {
if (d.x !== 1 && d.y !== 2) {
if (d.x !== undefined) { return 2; } else { return 1; }
} else { return 0; }
}
The assertion is in get_args_constr: https://github.com/rescript-lang/rescript/blob/8d51b9ce7/compiler/ml/matching.ml#L1233-L1236
The same crash happens with a record type that has optional fields, both at master and at ece8b148:
type r = {x?: int, y?: int}
let f = (d: r) =>
switch d {
| {x: 1} => 0
| {y: 2} => 0
| {x: ?None} => 1 // `?Some(3)` crashes too
| _ => 2
}
Any two of the three cases compile. The crash needs a value pattern and an optional pattern (?None or ?Some(_)) on the same key, with a case on another key between them.
Introduced
The record crash is older. Dict patterns reach it since #8751 (e6c46f23b), which lowers every key of a match to one optional record label: https://github.com/rescript-lang/rescript/blob/8d51b9ce7/compiler/ml/dict_pattern.ml#L73-L102
Impact
The compiler crashes, with no source location, on an ordinary dict pattern match that compiled before #8751.
- Ngôn ngữ chính
- OCaml
- Star
- 7.5k
- Fork
- 484
- Merge trung bình
- 20 giờ 27 phút
- Pull request đã merge (30 ngày)
- 120
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ó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
rescript-lang/rescript#8833 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
rewatch watch on Linux stops watching a source folder when an overlapping recursive source folder is removed from rescript.jsonCó thể đã có người làm @cknitt đã nhận 2 ngày trước. Đang mở
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 35/100
rescript-lang/rescript#8825 ·
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#8806 ·
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#8798 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 58/100
rescript-lang/rescript#8757 ·
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
limitlessprojects/Go-Hybrid#50 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Drawing: a reserved word as a view or sheet name says "is not a name" instead of "is reserved"Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
bmander/geomsolver#316 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
text as float loses precisionĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
NationalSecurityAgency/ghidra#9884 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
crash generated by fuzzer mlir
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
llvm/llvm-project#231844 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày