Skip to content

Missing unescaping when accessing prop with exotic name #7431

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

Closed
cknitt opened this issue May 5, 2025 · 2 comments · Fixed by #7469
Closed

Missing unescaping when accessing prop with exotic name #7431

cknitt opened this issue May 5, 2025 · 2 comments · Fixed by #7469
Labels
Milestone

Comments

@cknitt
Copy link
Member

cknitt commented May 5, 2025

In v12,

module MyWeirdComponent = {
  type props = {\"MyWeirdProp": string}

  let make = props =>
    <p>
      {React.string("foo")}
      {React.string(props.\"MyWeirdProp")}
    </p>
}

compiles to

function make(props) {
  return JsxRuntime.jsxs("p", {
    children: [
      "foo",
      props["\\\"MyWeirdProp\""]
    ]
  });
}

let MyWeirdComponent = {
  make: make
};

(note the "\\\"MyWeirdProp\"") whereas in v11 it used to be correct:

function make(props) {
  return JsxRuntime.jsxs("p", {
              children: [
                "foo",
                props.MyWeirdProp
              ]
            });
}

var MyWeirdComponent = {
  make: make
};
@nojaf
Copy link
Collaborator

nojaf commented May 6, 2025

Smaller sample to reproduce:

type props = {\"MyWeirdProp": float}
let x =  { \"MyWeirdProp": Math.random()}
Console.log(x.\"MyWeirdProp")

Link

@cristianoc would this be a problem at the end in js_dump or something happened during optimization?

@cknitt cknitt added the bug label May 6, 2025
@cknitt cknitt added this to the v12 milestone May 6, 2025
@cristianoc
Copy link
Collaborator

It could be the way the string is tagged, or the way js dump prints the prop name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants