Skip to content

Fix missing unescaping when accessing prop with exotic name #7469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions compiler/core/js_dump_property.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions tests/tests/src/gpr_7431_test.mjs
Original file line number Diff line number Diff line change
@@ -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 */
5 changes: 5 additions & 0 deletions tests/tests/src/gpr_7431_test.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type props = {\"MyWeirdProp": float}

let x = {\"MyWeirdProp": Math.random()}

Console.log(x.\"MyWeirdProp")
2 changes: 1 addition & 1 deletion tests/tests/src/jsx_preserve_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ let _external_component_with_children = <QueryClientProvider>
function Jsx_preserve_test$MyWeirdComponent(props) {
return <p>
{"foo"}
{props["\\\"MyWeirdProp\""]}
{props.MyWeirdProp}
</p>;
}

Expand Down