Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Fix support for recursive components in JSX4 #733

Merged
merged 5 commits into from
Feb 6, 2023
Merged

Conversation

mununki
Copy link
Member

@mununki mununki commented Feb 6, 2023

This PR fixes the issue rescript-lang/rescript-compiler#5981, backporting rescript-lang/rescript-compiler#5986 to syntax

@@ -1228,7 +1233,8 @@ let transformStructureItem ~config mapper item =
List.fold_right otherStructures structuresAndBinding ([], [], [])
in
types
@ [{pstr_loc; pstr_desc = Pstr_value (recFlag, bindings)}]
(* No need to be Recursive as internal representation is called *)
@ [{pstr_loc; pstr_desc = Pstr_value (Nonrecursive, bindings)}]
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not work with mutually recursive components. See example in the original PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is removed.

Copy link
Contributor

@cristianoc cristianoc left a comment

Choose a reason for hiding this comment

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

I think it works.

make(({}: props))
}
let make = {
let \"V4$Rec" = props => \"make$Internal"(props)
Copy link
Contributor

Choose a reason for hiding this comment

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

This part seems to be doing noting in the case of recursive functions.
That was true already before, so that's OK. Just, not very useful.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since recursive components are rare, let's just move on.

Copy link
Member Author

Choose a reason for hiding this comment

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

This part seems to be making this expression in js output:

function make(_props) {
  while(true) {
    _props = {};
    continue ;
  };
}

var V4$Rec = { // <- here
  make: make
};

@mununki mununki merged commit 623f196 into master Feb 6, 2023
@mununki mununki deleted the recursive-component-v4 branch February 7, 2023 00:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants