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

Loopy constraints cause ocamlc to loop #12145

Closed
goldfirere opened this issue Mar 30, 2023 · 3 comments
Closed

Loopy constraints cause ocamlc to loop #12145

goldfirere opened this issue Mar 30, 2023 · 3 comments
Assignees

Comments

@goldfirere
Copy link
Contributor

(Credit to @ccasin, who devised this example.)

When ocamlc sees

  type 'a t constraint 'a = 'b * 'c

  type cycle = cycle id
  and 'a id = 'a
  and s = cycle t

it goes into a loop and never returns. Tested on 5.0.0. 4.14.0 stack-overflows (but doesn't hang).

This is not a real problem for me or anyone else -- instead, it was what happened after I asked Chris "why do you think that the constraint consistency check for mutually recursive type definitions is OK before the well-foundedness check?". It turns out that it's likely not OK.

@ccasin
Copy link
Contributor

ccasin commented Mar 31, 2023

To be clear about "credit", @lpw25 and I devised this a while ago while trying to understand this part of type declaration checking. I should have reported it at the time, but there is some older issue I'm having trouble tracking down now that I thought might be the same problem (but I ran out of time thinking about that and then forgot about it until yesterday). As Richard says, I think this is more a curiosity than a real problem.

@gasche
Copy link
Member

gasche commented Apr 7, 2023

If we don't know how to order these tests, maybe we should try to check both well-formedness properties at once?

@garrigue
Copy link
Contributor

Actually here the loop is not in the constraint consistency check, but in update_types, whose role is to close the recursion between mutually recursive type abbreviations.
The point is that it should not call unify before checking well-foundedness. However, we do need to close the recursion, so there is no easy solution.

garrigue added a commit to COCTI/ocaml that referenced this issue Apr 13, 2023
garrigue added a commit to COCTI/ocaml that referenced this issue May 29, 2023
@gasche gasche closed this as completed in a84586d Jun 6, 2023
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

No branches or pull requests

4 participants