JSX preserve mode spreads an `@unboxed` props record (`{..."x"}` instead of `"x"`)
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được 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
- 25/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 jsx_props_of in compiler/ml/translcore.ml and jsx_printable in compiler/core/js_dump.ml, then compare the preserve-mode output with the reproduction and expected output in the issue. Done means both @unboxed record examples preserve the string as the props value instead of spreading it. Pull request #8847 is already open for this issue.
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
jsx_props_of turns every props expression that is not a Record_regular record literal into Jsx_props_spread:
https://github.com/rescript-lang/rescript/blob/8d51b9ce7/compiler/ml/translcore.ml#L1049-L1096
An @unboxed record literal compiles to its single field's value, which is not an object. jsx_printable does not reject this case:
https://github.com/rescript-lang/rescript/blob/8d51b9ce7/compiler/core/js_dump.ml#L176-L190
Reproduction
@@jsxConfig({version: 4, module_: "MyJsx"})
module MyJsx = {
type element = int
type component<'props> = 'props => element
external component: component<'props> => component<'props> = "%identity"
@module("rt") external jsx: (component<'props>, 'props) => element = "jsx"
@module("rt") external jsxs: (component<'props>, 'props) => element = "jsxs"
external array: array<element> => element = "%identity"
}
@unboxed type props = {title: string}
module C = {@module("lib") external make: MyJsx.component<props> = "C"}
module D = {@val external make: MyJsx.component<props> = "lowerD"}
let el = <C title="x" />
let el2 = <D title="y" />
bsc -nopervasives -bs-jsx 4 -bs-jsx-preserve K12.res at master:
let el = <Lib.C
{..."x"}
/>;
let el2 = Rt.jsx(lowerD, {..."y"});
Expected, as printed by bsc -nopervasives -bs-jsx 4 and by preserve mode at ece8b148:
let el = Rt.jsx(Lib.C, "x");
let el2 = Rt.jsx(lowerD, "y");
Introduced
#8754 (a7721303a).
Impact
The component receives {0: "x"} instead of "x": the generated code is wrong, with no error or warning. The case is rare, because the props type must be an @unboxed record.
- 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 1 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 62/100
NationalSecurityAgency/ghidra#9884 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
llvm.memcpy with destination align but no source align asserts "Missed Source alignment!"Có thể đã có người làm @pvelesko đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
KhronosGroup/SPIRV-LLVM-Translator#4093 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
UB: (int) cast of a user double outside int range in dispatch / vm_index_is_int / flat_index_atĐang mởarea:runtime-vm
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
InauguralSystems/EigenScript#1748 ·
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 76/100
leanprover/lean4#15677 ·
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 72/100
Maintainer thường phản hồi trong vòng 2 ngày