Untagged variant with Blob and File cases never matches File when Blob is declared first
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ó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/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
- Lĩnh vực
- compilers
Hướng nghiên cứu
Start with compiler/ml/ast_untagged_variants.ml, especially type_to_instanceof_backed_obj, and trace how untagged variant cases become ordered instanceof checks. Check the compiler tests for untagged variants and add coverage for File and Blob in both declaration orders. Done means the subclass case is matched first regardless of order, or the unsupported variant is rejected.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
An untagged variant with cases for a class and one of its subclasses tests them in declaration order, so the subclass case can never match when it is declared second:
@unboxed
type upload = Blob(Blob.t) | File(File.t)
let describe = u =>
switch u {
| Blob(_) => "blob"
| File(_) => "file"
}
compiles to
function describe(u) {
if (u instanceof Blob) {
return "blob";
} else {
return "file";
}
}
File extends Blob, so for File(new File(["x"], "a.txt")) the check u instanceof Blob is true and describe returns "blob" (checked in Node). Declaring File(File.t) | Blob(Blob.t) instead emits u instanceof File and works, whatever the order of the switch cases.
Expected: a subclass is tested before its superclass regardless of declaration order, or the variant is rejected.
Cause: type_to_instanceof_backed_obj in compiler/ml/ast_untagged_variants.ml maps a fixed list of stdlib type names to classes but records no relation between them, so the tests are emitted in declaration order. File/Blob is the only subclass pair in that list today. The same question comes up for user-declared classes (e.g. HTMLElement extends Element) if bindings can declare their runtime class.
Reproduced on current master.
- Ngôn ngữ chính
- ReScript
- Star
- 7.5k
- Fork
- 483
- Merge trung bình
- 1 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 164
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
-
RFC: Generator functionsĐang mởdiscussion enhancement
Độ 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#8934 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Partial application moves its arguments into the generated closureCó thể đã có người làm @cknitt đã nhận 1 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
rescript-lang/rescript#8932 ·
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#8910 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Nested JSX components under React Server Components: derive flat exports from the signatureCó thể đã có người làm @cknitt đã nhận 3 ngày trước. Đang mở
Độ 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#8901 ·
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#8897 ·
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ự
-
bug priority: P2
Độ khó 1/5 Dưới một 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
-
confirmed generated by fuzzer llvm:optimizations miscompilation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
llvm/llvm-project#234325 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
grammar selfhost sev-3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Support underscore in modulesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
gren-lang/compiler-common#41 ·