JSX preserve mode spreads an `@unboxed` props record (`{..."x"}` instead of `"x"`)
Maintainer antworten meist innerhalb von 1 Tag
Ein zugehöriger Pull Request wurde bereits gemerged.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- javascript, ocaml
- Bereich
- compilers
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- ReScript
- Sterne
- 7.5k
- Forks
- 483
- Ø Merge
- 1 T. 1 Std.
- Gemergte PRs (30 T.)
- 120
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus rescript-lang/rescript
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
rescript-lang/rescript#8833 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
rewatch watch on Linux stops watching a source folder when an overlapping recursive source folder is removed from rescript.jsonEvtl. vergeben @cknitt hat das vor 3 Tagen übernommen. Offen
Schwierigkeit 4/5 1-2 Tage Anfängerfreundlichkeit 35/100
rescript-lang/rescript#8825 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
rescript-lang/rescript#8806 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
rescript-lang/rescript#8798 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 Ein halber Tag Anfängerfreundlichkeit 58/100
rescript-lang/rescript#8757 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in rescript-lang/rescript
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 1 Tag
-
A `--symbolic` entry binding `𝑛3` and `!n3` passes the load check, since `once` compares spellings, and fails mid-run with a `user error`Evtl. vergeben @sherenkov hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
objectionary/phino#1929 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
FuRongJun-1999/dsh-memory#402 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100