Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

JSX preserve mode spreads an `@unboxed` props record (`{..."x"}` instead of `"x"`)

オープン
#8,813 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@cknitt がすでに取り組んでいます。

2026年10月12日 から。

  • #8847 @cknitt による — オープン

評価

難易度
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

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rescript-lang/rescript のほかの issue

rescript-lang/rescript の issue をすべて見る

似ている issue

Compilers の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。