From 3805379bd3dd3d0c108385b8e699b1d3afdac2a1 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Tue, 13 May 2025 17:09:15 +0200 Subject: [PATCH 1/2] Fix missing unescaping when accessing prop with exotic name --- compiler/core/js_dump_property.ml | 1 + tests/tests/src/gpr_7431_test.mjs | 13 +++++++++++++ tests/tests/src/gpr_7431_test.res | 5 +++++ tests/tests/src/jsx_preserve_test.mjs | 2 +- 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/tests/src/gpr_7431_test.mjs create mode 100644 tests/tests/src/gpr_7431_test.res diff --git a/compiler/core/js_dump_property.ml b/compiler/core/js_dump_property.ml index 6df115808b..3b716be029 100644 --- a/compiler/core/js_dump_property.ml +++ b/compiler/core/js_dump_property.ml @@ -68,6 +68,7 @@ let obj_property_no_need_quot s = ]} *) let property_access f s = + let s = Ext_ident.unwrap_uppercase_exotic s in if obj_property_no_need_quot s then ( P.string f L.dot; P.string f s) diff --git a/tests/tests/src/gpr_7431_test.mjs b/tests/tests/src/gpr_7431_test.mjs new file mode 100644 index 0000000000..d7d2cee283 --- /dev/null +++ b/tests/tests/src/gpr_7431_test.mjs @@ -0,0 +1,13 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let x = { + MyWeirdProp: Math.random() +}; + +console.log(x.MyWeirdProp); + +export { + x, +} +/* x Not a pure module */ diff --git a/tests/tests/src/gpr_7431_test.res b/tests/tests/src/gpr_7431_test.res new file mode 100644 index 0000000000..35e931b198 --- /dev/null +++ b/tests/tests/src/gpr_7431_test.res @@ -0,0 +1,5 @@ +type props = {\"MyWeirdProp": float} + +let x = {\"MyWeirdProp": Math.random()} + +Console.log(x.\"MyWeirdProp") diff --git a/tests/tests/src/jsx_preserve_test.mjs b/tests/tests/src/jsx_preserve_test.mjs index 529ab697ef..5a3ddc0ca0 100644 --- a/tests/tests/src/jsx_preserve_test.mjs +++ b/tests/tests/src/jsx_preserve_test.mjs @@ -147,7 +147,7 @@ let _external_component_with_children = function Jsx_preserve_test$MyWeirdComponent(props) { return

{"foo"} - {props["\\\"MyWeirdProp\""]} + {props.MyWeirdProp}

; } From 2a79e328d9bcf49caedd83b542fc4cecf7353b71 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Tue, 13 May 2025 17:12:08 +0200 Subject: [PATCH 2/2] CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 637f479aad..42f8ffe797 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ - Fix missing checks for duplicate literals in variants with payloads. https://github.com/rescript-lang/rescript/pull/7441 - Fix printer removing private for empty record. https://github.com/rescript-lang/rescript/pull/7448 - Fix: handle dynamic imports with module aliases. https://github.com/rescript-lang/rescript/pull/7452 +- Fix missing unescaping when accessing prop with exotic name. https://github.com/rescript-lang/rescript/pull/7469 #### :house: Internal