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

Top-level printer crash with recursively-constrained type #9873

Closed
yallop opened this issue Sep 3, 2020 · 5 comments
Closed

Top-level printer crash with recursively-constrained type #9873

yallop opened this issue Sep 3, 2020 · 5 comments

Comments

@yallop
Copy link
Member

yallop commented Sep 3, 2020

This looks somewhat related to #9866 (cc @garrigue):

In 4.11.1:

# type 'a t = 'b constraint 'a = ('b * 'b) t ;;
Line 1, characters 0-42:
1 | type 'a t = 'b constraint 'a = ('b * 'b) t ;;
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: In this definition, a type variable cannot be deduced
       from the type parameters.

In trunk:

# type 'a t = 'b constraint 'a = ('b * 'b) t ;;
type 'a t = 'b constraint 'a = ('b * 'b) t
# ([|Some 3L|], [|None|] :  _ t  );;
Segmentation fault
@garrigue
Copy link
Contributor

garrigue commented Sep 3, 2020

Unfortunately, #9870 does not fix that one. Pandora box ?

garrigue added a commit to garrigue/ocaml that referenced this issue Sep 3, 2020
@garrigue
Copy link
Contributor

garrigue commented Sep 3, 2020

Fixed in #9870. The cause was a use of Ctype.apply which does not handle properly constrained parameters.
Maybe Ctype.apply itself should be removed in most cases.

@garrigue
Copy link
Contributor

garrigue commented Sep 3, 2020

Note that the bug was in the printer, not the type-checker, but the faulty function is exported from the type checker (it is very seldom used, hopefully on types without constraints).

@garrigue
Copy link
Contributor

garrigue commented Sep 3, 2020

Actually the problem is not in the printer; using #9870 we get:

# fun () -> (1,2 : _ t);;
- : unit -> (int * int) t t = <fun>

which is clearly wrong. I'm starting to get completely lost. Somehow the type checker seems to believe parameters are regular too... Now looking into how to get rid of those strange type definitions.

@Octachron
Copy link
Member

I am closing this issue as a duplicate of #9866 (which is still open for recursive module).

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

3 participants