-
Notifications
You must be signed in to change notification settings - Fork 459
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
Fix issue with JSX V4 when components are nested #6031
Conversation
28258d2
to
95e5923
Compare
Fixes #5975 The issue is due to a combination of: 1) when a component let make = body is transformed, first the body is transformed, then when transformStructureItem4 is called, the body is transformed again 2) @react.component is left after the PPX transformation Because of this, in the case of nested components, the transformed inner components is transformed again by transformStructureItem4, but it should not as it's been desugared already. It would be enough to change either one, to avoid the error with nested components, but this PR handles both aspects.
95e5923
to
eb623b7
Compare
Isn't it still valid to be a transformation from inside? I'm not sure why we're deleting the mapper, it seems like we only need to remove the |
@@ -127,8 +127,8 @@ let getMapper ~config = | |||
| Pstr_attribute attr -> processConfigAttribute attr config | |||
| _ -> ()); | |||
let item = default_mapper.structure_item mapper item in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This applies the JSX transformation recursively to the structure item.
@@ -127,8 +127,8 @@ let getMapper ~config = | |||
| Pstr_attribute attr -> processConfigAttribute attr config | |||
| _ -> ()); | |||
let item = default_mapper.structure_item mapper item in | |||
if config.version = 3 then transformStructureItem3 mapper item | |||
else if config.version = 4 then transformStructureItem4 mapper item |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was applying the JSX transformation recursively again, to some parts of the structure item.
See the comment here: https://github.com/rescript-lang/rescript-compiler/pull/6031/files#r1125400463 |
@@ -446,8 +446,7 @@ let jsxMapper ~config = | |||
args | |||
in | |||
|
|||
let rec recursivelyTransformNamedArgsForMake mapper expr args newtypes = | |||
let expr = mapper.expr mapper expr in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would apply the entire JSX transform again, to expr
, every time this function is entered.
I guess at best this would do nothing as the transform has happened already.
If it does something, it's probably not going to be something good.
Am I missing something @mununki ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why I didn't realize it didn't need this.
@mununki any last thoughts on this? Going to merge this soon, as it's the last outstanding fix remaining for release 10.1.3. |
Sorry for coming back so late, I didn't want to be a blocker. |
Later on one can clean up the code, and move the line |
Fixes #5975
The issue is due to a combination of:
Because of this, in the case of nested components, the transformed inner components is transformed again by transformStructureItem4, but it should not as it's been desugared already.
It would be enough to change either one, to avoid the error with nested components, but this PR handles both aspects.