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

OCaml compiler loops on an example using GADTs #6174

Closed
vicuna opened this issue Sep 12, 2013 · 2 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link

commented Sep 12, 2013

Original bug ID: 6174
Reporter: ckeller
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:24:17Z)
Resolution: fixed
Priority: normal
Severity: major
Version: 4.00.1
Fixed in version: 4.01.1+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @gasche

Bug description

The OCaml compiler seems to loop on the following program (which I also attached):

type _ t = C : ((('a -> 'o) -> 'o) -> ('b -> 'o) -> 'o) t
let f : type a o. ((a -> o) -> o) t -> (a -> o) -> o =
fun C k -> k (fun x -> x)

Additional information

It loops as well with the version 4.02.0dev+trunk installed with opam.

File attachments

@vicuna

This comment has been minimized.

Copy link
Author

commented Oct 12, 2013

Comment author: hnrgrgr

After some debugging, the loop appears in the 'lower_args' function while type-checking the application (in Typecore.type_expect_, case Pexp_apply).

There is the following equalities "o = ex#2 -> ex#1" where "ex#1 = ex#2 -> ex#1". Each expansion of ex#1 allocates an new 'type_expr', and the 'seen' list is infinitely growing.

Still, I do not understand why the following generalisation is accepted:

type _ t = C : ((('a -> 'o) -> 'o) -> ('b -> 'o) -> 'o) t
let f = fun C -> ()
let f1 : type a o. ((a -> o) -> o) t -> unit = f (* refused )
let f2 : type a o. ((a -> o) -> o) t -> unit = fun C -> () (
accepted *)

@vicuna

This comment has been minimized.

Copy link
Author

commented Oct 28, 2013

Comment author: @garrigue

Fixed in 4.01 and trunk, revisions 14246-14248.
In 4.01 only the non-rectypes case is fixed (was due to a typo).
Trunk fully fixes the problem, by ensuring that the abbreviation cache is not cleared in the middle of a potentially recursive traversal (some other cases may still be there).

@vicuna vicuna closed this Dec 11, 2015

@vicuna vicuna added the bug label Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.