Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006174OCamlOCaml generalpublic2013-09-12 19:072013-10-28 13:13
Reporterckeller 
Assigned Togarrigue 
PrioritynormalSeveritymajorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.00.1 
Target VersionFixed in Version4.01.1+dev 
Summary0006174: OCaml compiler loops on an example using GADTs
DescriptionThe 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 InformationIt loops as well with the version 4.02.0dev+trunk installed with opam.
TagsNo tags attached.
Attached Files? file icon loop.ml [^] (141 bytes) 2013-09-12 19:07 [Show Content]

- Relationships

-  Notes
(0010461)
hnrgrgr (developer)
2013-10-12 23:12

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 *)
(0010532)
garrigue (manager)
2013-10-28 13:13

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).

- Issue History
Date Modified Username Field Change
2013-09-12 19:07 ckeller New Issue
2013-09-12 19:07 ckeller File Added: loop.ml
2013-10-12 23:12 hnrgrgr Note Added: 0010461
2013-10-28 13:13 garrigue Note Added: 0010532
2013-10-28 13:13 garrigue Status new => resolved
2013-10-28 13:13 garrigue Fixed in Version => 4.01.1+dev
2013-10-28 13:13 garrigue Resolution open => fixed
2013-10-28 13:13 garrigue Assigned To => garrigue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker