JSX preserve mode spreads an `@unboxed` props record (`{..."x"}` instead of `"x"`)
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- javascript, ocaml
- 領域
- compilers
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- OCaml
- スター
- 7.5k
- フォーク
- 484
- 平均マージ
- 18時間 19分
- マージ済み PR(30日)
- 116
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rescript-lang/rescript のほかの issue
-
Build-test fixtures that no longer test what they claim対応中かも @cknitt が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
rescript-lang/rescript#8827 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
rescript-lang/rescript#8833 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
rewatch watch on Linux stops watching a source folder when an overlapping recursive source folder is removed from rescript.json対応中かも @cknitt が 1 日前に担当しました。 オープン
難易度 4/5 1〜2日 初心者へのやさしさ 35/100
rescript-lang/rescript#8825 ·
メンテナーはふだん 1 日以内に返信
-
Formatter drops comments in dict patterns, variant spread patterns and dict literal spreads対応中かも @cknitt が 1 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
rescript-lang/rescript#8820 ·
メンテナーはふだん 1 日以内に返信
-
Compiler crash (matching.ml assertion) on dict and optional-field record patterns mixing a value and `?None` on one key対応中かも @cknitt が 1 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
rescript-lang/rescript#8810 ·
メンテナーはふだん 1 日以内に返信
rescript-lang/rescript の issue をすべて見る
似ている issue
-
UB: (int) cast of a user double outside int range in dispatch / vm_index_is_int / flat_index_atオープンarea:runtime-vm
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
InauguralSystems/EigenScript#1748 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
KhronosGroup/glslang#4469 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
bradcypert/plum#319 ·
メンテナーはふだん 1 日以内に返信
-
[llvm-cov] `export -format=lcov` writes the folded side of a branch as an untaken `BRDA` recordオープンtools:llvm-cov
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
llvm/llvm-project#231521 ·
メンテナーはふだん 1 日以内に返信