Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007699OCamltypingpublic2017-12-24 09:102018-01-12 14:01
Assigned To 
StatusresolvedResolutionnot fixable 
PlatformOSOS Version
Product Version4.06.0 
Target VersionFixed in Version 
Summary0007699: Recursive modules don't normalize type aliases correctly
DescriptionGiven two recursive modules `T1` and `T2`, and an opaque type `T1.t` which is equal to `b`, references to `T1.t` in `T2` are not normalized to have type `b` in `T1`.

Steps To Reproduce```
module rec Foo : sig
  val make: Bar.t
end = struct
  let make = Bar.make
end and Bar : sig
  type t
  val make: t
end = struct
  type t = unit
  let make = ()
  let _: unit = Foo.make

gives the error:

File "./", line 11, characters 16-24:
Error: This expression has type Bar.t but an expression was expected of type
Additional InformationOne can get around this issue by not using type aliases - I've gotten around this in my own code with a single-variant variant type.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
lpw25 (developer)
2017-12-24 10:17

This is a well-known issue with recursive modules called the "double-vision" problem. There are some recursive module systems that avoid it -- see various works by Dreyer and Rossberg -- but changing OCaml's module system to match one of those would be a significant piece of work, so don't expect this to be fixed any time soon.
ubsan (reporter)
2017-12-24 10:24
edited on: 2017-12-24 20:00

dang :(

Well, I guess it can be closed then? Or maybe it should become a docs bug

xleroy (administrator)
2018-01-12 14:00

In this particular case you can also export "Bar.t" transparently:

and Bar : sig type t = unit ... end = ...

- Issue History
Date Modified Username Field Change
2017-12-24 09:10 ubsan New Issue
2017-12-24 10:17 lpw25 Note Added: 0018785
2017-12-24 10:24 ubsan Note Added: 0018786
2017-12-24 20:00 ubsan Note Edited: 0018786 View Revisions
2018-01-12 14:00 xleroy Note Added: 0018828
2018-01-12 14:01 xleroy Status new => resolved
2018-01-12 14:01 xleroy Resolution open => not fixable

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker