Record coercion can construct a private record from outside its module
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
- #9125 của @cknitt — đã merge
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 52/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
Start by tracing the record coercion type-checking path in the ReScript compiler and compare it with the handling of mutable from #9063, fixed by #9086. Check both examples in this issue: coercion from a plain record and from another module’s private record should be rejected, while coercion out to a plain record should remain allowed. Done means those cases behave as expected and the compiler’s relevant regression tests pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
A record coerces structurally into a private record with the same fields, so code outside a module can construct values of that module's private record type, although private means they can only be built inside it.
From a plain record:
module Blob: {
type t = private {size: float}
} = {
type t = {size: float}
}
type plain = {size: float}
let fake = (p: plain): Blob.t => (p :> Blob.t) // compiles: `return p`
From another module's private record with the same fields, which that module constructs freely:
module Fake: {
type t = private {size: float}
let make: float => t
} = {
type t = {size: float}
let make = size => {size: size}
}
let forged = (Fake.make(1.) :> Blob.t) // compiles: `{size: 1}`
Expected: a coercion into a private record type is refused, unless the source is that same type. Coercing out of a private record, into a plain record with the same fields, stays allowed: reading a private record is fine.
This is a prerequisite for @instanceOf on private records (#9058): there, a forged value would be dispatched as an instance of a class it isn't. It is the same family as #9063 (fixed by #9086), where record coercion ignored mutable.
Found on master 3562ce6b80.
- Ngôn ngữ chính
- OCaml
- Star
- 7.5k
- Fork
- 484
- Merge trung bình
- 21 giờ 9 phút
- Pull request đã merge (30 ngày)
- 255
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
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
rescript-lang/rescript#9135 ·
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
rescript-lang/rescript#9132 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Printed type declarations drop @tag, @notUndefined and runtime annotationsCó thể đã có người làm @cknitt đã nhận hôm nay. Đang mở
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 25/100
rescript-lang/rescript#9134 ·
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#9130 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 55/100
rescript-lang/rescript#9122 ·
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 76/100
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
CanadaHonk/porffor#426 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
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 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
compiler-rt:asan llvm:transforms
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
llvm/llvm-project#236682 ·
Maintainer thường phản hồi trong vòng 1 ngày