Skip to content

Pass existing location to children prop#7540

Merged
nojaf merged 6 commits into
rescript-lang:masterfrom
nojaf:jsx-ast-children-loc
Jun 19, 2025
Merged

Pass existing location to children prop#7540
nojaf merged 6 commits into
rescript-lang:masterfrom
nojaf:jsx-ast-children-loc

Conversation

@nojaf

@nojaf nojaf commented Jun 6, 2025

Copy link
Copy Markdown
Member

Fixes #7537
Fixes #7538

@pkg-pr-new

pkg-pr-new Bot commented Jun 6, 2025

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7540

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7540

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7540

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7540

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7540

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7540

commit: e90cb2f

@nojaf

nojaf commented Jun 6, 2025

Copy link
Copy Markdown
Member Author

@mediremi could you try this one out please?

addValueReference ComponentAsProp.res:12:24 --> ComponentAsProp.res:12:13
addValueReference ComponentAsProp.res:13:16 --> React.res:3:0
addValueReference ComponentAsProp.res:11:14 --> ComponentAsProp.res:6:34
addValueReference ComponentAsProp.res:9:6 --> ComponentAsProp.res:6:12

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zth, any thoughts on whether this is problematic or not?

Comment thread compiler/syntax/src/jsx_v4.ml Outdated
| _generic -> module_access_name config "Elements"
in
Exp.apply
Exp.apply ~loc:child.pexp_loc

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this change is responsible for the changes in the dead code analysis. But this change does not seem necessary to fix the location issue in error messages.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have an explanation as to why this would happen. More non-dummy locations should lead to more value dependencies found in the dead code analysis, which just traverses the typed ast.
Unless, somehow, this change affects the locations produced during type inference.

@mediremi

mediremi commented Jun 8, 2025

Copy link
Copy Markdown
Member

@nojaf I've tested this PR on my project and it fixes the issues I encountered 🎉 Thanks for fixing this 🙏

addValueReference ComponentAsProp.res:12:24 --> ComponentAsProp.res:12:13
addValueReference ComponentAsProp.res:13:16 --> React.res:3:0
addValueReference ComponentAsProp.res:11:14 --> ComponentAsProp.res:6:34
addValueReference ComponentAsProp.res:9:6 --> ComponentAsProp.res:6:12

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more of these missing - perhaps another exp apply with loc?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cristianoc, I'm not entirely sure how this works, but since addValueReference ComponentAsProp.res:9:6 --> ComponentAsProp.res:6:12 is mentioned a few lines above in this file, could this mean that it's fine and there's no risk of duplication?

Or do you think we should aim for no changes in this file? Does it matter?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh removing duplications is pretty likely OK. If that's all there is, I think we can safely push on.

@fhammerschmidt fhammerschmidt added this to the v12 milestone Jun 12, 2025
@nojaf nojaf marked this pull request as ready for review June 19, 2025 13:05
@nojaf nojaf merged commit 3d45c38 into rescript-lang:master Jun 19, 2025
17 checks passed
@github-actions github-actions Bot deleted the jsx-ast-children-loc branch March 4, 2026 00:45
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 this pull request may close these issues.

"no children prop" error does not show line number "Missing required props" error does not show line number when component has children prop

4 participants