Coercion hint suggests the inner type when the mismatch is nested
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ó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 75/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- ocaml
- Lĩnh vực
- compilers
Hướng nghiên cứu
Bản sửa lỗi nằm trong compiler/ml/error_message_utils.ml: xác định vị trí nơi gợi ý coercion được xây dựng từ target_type và thay đổi nó để sử dụng top_level_types. Biên dịch đoạn mã ReScript từ issue để tái tạo gợi ý sai. Hoàn thành khi coercion được đề xuất là (make :> unit => iterable<int>) và ví dụ biên dịch được.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When a type mismatch is nested inside another type, the "compatible at runtime" hint suggests a coercion to the inner type instead of the whole expected type, and the suggested code doesn't compile.
let consume = (_f: unit => Iterable.t<int>) => ()
let make: unit => Generator.t<int, unit, unit> = %raw(`function* () { yield 1 }`)
let () = consume(make)
This has type: unit => Generator.t<int, unit, unit>
But this function argument is expecting: unit => Iterable.t<int>
The incompatible parts:
Generator.t<int, unit, unit> (defined as Generator.t<int, unit, unit>) vs
Iterable.t<int> (defined as iterable<int>)
Possible solutions:
- These types are compatible at runtime. You can use the coercion operator to convert to the expected type: (make :> iterable<int>)
Applying the suggestion fails with Type unit => Generator.t<int, unit, unit> is not a subtype of iterable<int>. The right suggestion is (make :> unit => iterable<int>), which compiles.
Cause
In compiler/ml/error_message_utils.ml, the hint checks Ctype.subtype on the top-level types of the trace (top_level_types, "Coercion should always target the top level types"), but builds the rewrite from target_type, which is the inner incompatible pair. Printing the top-level expected type instead should fix it.
(The doubled Generator.t<…> (defined as Generator.t<…>) in the same output is #8997.)
- Ngôn ngữ chính
- OCaml
- Star
- 7.5k
- Fork
- 483
- Merge trung bình
- 19 giờ 35 phút
- Pull request đã merge (30 ngày)
- 208
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
-
Per-constructor @unboxed is not compared across interfaces or coercionsCó 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#9038 ·
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#9006 · 1 reaction ·
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 70/100
rescript-lang/rescript#8997 ·
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 68/100
rescript-lang/rescript#8994 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
@notUndefined in an interface is not checked against the implementationCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
rescript-lang/rescript#8964 · 1 bình luận ·
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ự
-
Recover inside a parameter listĐang mởenhancement scope:diagnostics scope:syntax
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
-
code: refactoring good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
idris-lang/Idris2#3887 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend:X86 generated by fuzzer llvm:globalisel miscompilation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
llvm/llvm-project#235468 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:codegen backend:cuda backend:hip bug direction:input
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
CrossGL/crosstl#3061 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100