Skip to content

Commit a838193

Browse files
authored
Fix missing unescaping when accessing prop with exotic name (#7469)
* Fix missing unescaping when accessing prop with exotic name * CHANGELOG
1 parent 3c4b033 commit a838193

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
- Fix missing checks for duplicate literals in variants with payloads. https://github.com/rescript-lang/rescript/pull/7441
3737
- Fix printer removing private for empty record. https://github.com/rescript-lang/rescript/pull/7448
3838
- Fix: handle dynamic imports with module aliases. https://github.com/rescript-lang/rescript/pull/7452
39+
- Fix missing unescaping when accessing prop with exotic name. https://github.com/rescript-lang/rescript/pull/7469
3940

4041
#### :house: Internal
4142

compiler/core/js_dump_property.ml

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ let obj_property_no_need_quot s =
6868
]}
6969
*)
7070
let property_access f s =
71+
let s = Ext_ident.unwrap_uppercase_exotic s in
7172
if obj_property_no_need_quot s then (
7273
P.string f L.dot;
7374
P.string f s)

tests/tests/src/gpr_7431_test.mjs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Generated by ReScript, PLEASE EDIT WITH CARE
2+
3+
4+
let x = {
5+
MyWeirdProp: Math.random()
6+
};
7+
8+
console.log(x.MyWeirdProp);
9+
10+
export {
11+
x,
12+
}
13+
/* x Not a pure module */

tests/tests/src/gpr_7431_test.res

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
type props = {\"MyWeirdProp": float}
2+
3+
let x = {\"MyWeirdProp": Math.random()}
4+
5+
Console.log(x.\"MyWeirdProp")

tests/tests/src/jsx_preserve_test.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ let _external_component_with_children = <QueryClientProvider>
147147
function Jsx_preserve_test$MyWeirdComponent(props) {
148148
return <p>
149149
{"foo"}
150-
{props["\\\"MyWeirdProp\""]}
150+
{props.MyWeirdProp}
151151
</p>;
152152
}
153153

0 commit comments

Comments
 (0)