Skip to content

Commit 3805379

Browse files
committed
Fix missing unescaping when accessing prop with exotic name
1 parent 3c4b033 commit 3805379

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

compiler/core/js_dump_property.ml

Lines changed: 1 addition & 0 deletions
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

Lines changed: 13 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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)