Skip to content

JSX4: loc missing in error for not existing prop #5957

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 Jan 26, 2023 · 5 comments · Fixed by #5960
Closed

JSX4: loc missing in error for not existing prop #5957

cknitt opened this issue Jan 26, 2023 · 5 comments · Fixed by #5960
Assignees
Milestone

Comments

@cknitt
Copy link
Member

cknitt commented Jan 26, 2023

In certain cases, when referencing a prop that does not exist, the loc information seems to get lost.

E.g. for

module A = {
  @react.component
  let make = () => React.null
}

@react.component
let make = () => <A someProp={<div />} />

the error message does not show in which line the error occurred:

  This record expression is expected to have type A.props
  The field someProp does not belong to type A.props

and the error is shown in VS Code like this:

Bildschirm­foto 2023-01-26 um 10 32 57

Compare with this case which works fine:

module A = {
  @react.component
  let make = () => React.null
}

@react.component
let make = () => <A someProp="test" />

It gives

  6 │ @react.component
  7 │ let make = () => <A someProp="test" />
  8 │

  This record expression is expected to have type A.props
  The field someProp does not belong to type A.props

Bildschirm­foto 2023-01-26 um 10 38 25

@mununki
Copy link
Member

mununki commented Jan 28, 2023

I couldn't reproduce the error msg without loc for the example with master, 10.1_release, or the latest pre-release compiler.
image
image
Can you confirm what version of the compiler shows the error without loc?

@cknitt
Copy link
Member Author

cknitt commented Jan 28, 2023

@mununki Sorry for not specifying this in detail. I am using 10.1.1 with JSX4 automatic mode.

It seems the problem occurs in automatic mode only. You can also check this here (upcoming 10.1.2 playground, not sure how long the link will work): https://rescript-lang-7alwuc0qv-rescript-association.vercel.app/try?version=v10.1.2&code=ALBWGcA8GEHsDsBmBLA5gCgN4AIBuBTAJ3GQQC5sAWAGmwFtYATfCgIgEMBXAF1jve7IAxq2wBfAJQAoKQ0acANvmwBBbAF5smKdmzBC+dkO4A6IXwAOCfPG47sS7vXYBrZZvQSNAPmwAlQ2MTeEUFKTEZfUDTczoreBs7R2c3DWxPH2wAHjVwPnwABUJYC3VMLMZkXGwAem8xWu8pIA

@mununki
Copy link
Member

mununki commented Jan 28, 2023

The simple example would be:

@@jsxConfig({version:4, mode: "automatic"})
let _ = <A someProp={<b />} />

I found that the loc of `someProp" is missing in three cases:

  • classic, Uppercase someProp={<B />}
  • automatic, Uppercase someProp={<B />}
  • automatic, lowercase someProp={<b />}

Only classic, lowercase someProp={<b />} keeps the loc.

I'll look into it.

@mununki
Copy link
Member

mununki commented Jan 28, 2023

@cknitt Can you try to test with #5960?

@cknitt
Copy link
Member Author

cknitt commented Jan 28, 2023

@mununki Just tested it and it looks good with #5960. Thanks a lot for your work!

@cristianoc cristianoc added this to the v10.1 milestone Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants