Skip to content

Pass existing location to children prop #7540

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 6 commits into from
Jun 19, 2025

Conversation

nojaf
Copy link
Collaborator

@nojaf nojaf commented Jun 6, 2025

Fixes #7537
Fixes #7538

Copy link

pkg-pr-new bot commented Jun 6, 2025

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
Copy link
Collaborator Author

nojaf commented Jun 6, 2025

@mediremi could you try this one out please?

@@ -23,21 +23,6 @@
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
Collaborator 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?

@@ -1208,7 +1208,7 @@ let append_children_prop (config : Jsx_common.jsx_config) mapper
| "react" -> Lident "ReactDOM"
| _generic -> module_access_name config "Elements"
in
Exp.apply
Exp.apply ~loc:child.pexp_loc
Copy link
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
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
Copy link
Contributor

mediremi commented Jun 8, 2025

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

@@ -28,16 +28,6 @@
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
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
Collaborator 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
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
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