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

Fix substitution of type params #542

Merged
merged 7 commits into from
Dec 8, 2020
Merged

Conversation

Julow
Copy link
Collaborator

@Julow Julow commented Dec 4, 2020

Fix #538 and #462

This substitutes recursively type variables when encountering a "replaced" type.

Use an explicit `'a or_replaced` type to better track where this need to
be handled.
test/xref2/gen.ml Outdated Show resolved Hide resolved
Comment on lines +642 to +643
| Replaced (TypeExpr.Constr (p, _), _) -> p
| Replaced _ -> (* What else is possible ? *) assert false
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure what we should do here. More tests are required

module M/68 : sig
type t/72
include : S/69 with [root(S/69).t = [(alias (poly_var [ `A of (a * b) ]) b)] t/72] (sig =
val map/73 : ([(alias (poly_var [ `A of (a * b) ]) b)] t/72) -> ((a) -> b) -> [(alias (poly_var [ `A of (b * b) ]) b)] t/72
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've found an edge case, the last type is wrong: (alias (poly_var [ A of (b * b) ]) b). We should either rename btoc` in this type or choose a free variable before substituting.
What do you think ?

Julow added 4 commits December 7, 2020 19:55
Print type representation in declarations.
Print polymorphic variants.
Add missing parentheses around arrows arguments and shorten some paths.
@jonludlam jonludlam merged commit 1a2b595 into ocaml:master Dec 8, 2020
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.

Wrong type after substitution
2 participants