Skip to content

Unboxed variant doesn't work when a payload record is defined in the recursive type definition #7314

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

Closed
DZakh opened this issue Feb 22, 2025 · 2 comments · Fixed by #7320
Closed

Comments

@cristianoc
Copy link
Collaborator

cristianoc commented Mar 6, 2025

It seems the definition of object2 is not found when the well formedness check for unboxed variants is triggered.
That's likely caused by how recursive types are handled, in that when the check is triggered we're still in the middle of type checking the recursive definitions.

type rec object2 = {foo: string}
@unboxed and tagged2 = Object(object2) | Fn(unit => object2)

cristianoc added a commit that referenced this issue Mar 6, 2025
Fixes #7314

- Delay untagged variant well-formedness checks until after environment construction
- Collect all untagged variant checks during type declaration processing
- Perform checks once all recursive types are available in the environment
- Add test case for valid recursive untagged variant type definitions

This fixes issues where recursive references in untagged variants would fail validation due to premature checking before the full type environment was built.
cristianoc added a commit that referenced this issue Mar 6, 2025
Fixes #7314

- Delay untagged variant well-formedness checks until after environment construction
- Collect all untagged variant checks during type declaration processing
- Perform checks once all recursive types are available in the environment
- Add test case for valid recursive untagged variant type definitions

This fixes issues where recursive references in untagged variants would fail validation due to premature checking before the full type environment was built.
cristianoc added a commit that referenced this issue Mar 6, 2025
Fixes #7314

- Delay untagged variant well-formedness checks until after environment construction
- Collect all untagged variant checks during type declaration processing
- Perform checks once all recursive types are available in the environment
- Add test case for valid recursive untagged variant type definitions

This fixes issues where recursive references in untagged variants would fail validation due to premature checking before the full type environment was built.
@DZakh
Copy link
Member Author

DZakh commented Mar 6, 2025

Nice, thank you very much 🙏

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 a pull request may close this issue.

2 participants