Skip to content
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

PPX: mutual recursion with records is now compiling. #295

Merged
merged 2 commits into from
Dec 5, 2024

Conversation

Kakadu
Copy link
Contributor

@Kakadu Kakadu commented Nov 21, 2024

Previously, the code like below was not compiling because 'n' argument was being forgotten. I added a dirty hack of treating all types in mutual block as recursive. Don't know is it a right solution but it seems to help

type tree = Leaf | Node of  tree * tree
and name  = { a: tree }
[@@deriving qcheck2]

Previously it gave an error: n is unbound

It looks like if we have mutually recursive types (algebraic + record)
It doesn't generate 'n' argument for record, because it thinks that
a record is not recursive by itself.

It was fixed by treating all mutually recurusive types as recursive
ones.

Signed-off-by: Kakadu <[email protected]>
@jmid
Copy link
Collaborator

jmid commented Dec 5, 2024

LGTM! FTR, I consider this a natural fix for the issue - and it even comes as a slight code simplification.

Merging ... thanks!

@jmid jmid merged commit 2888256 into c-cube:main Dec 5, 2024
13 checks passed
@Kakadu Kakadu deleted the ppx-records-rec-rebase branch December 5, 2024 13:39
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.

2 participants