Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006323OCamltypingpublic2014-02-06 18:592017-03-14 04:20
Assigned Togarrigue 
PlatformOSOS Version
Product Version4.01.0 
Target VersionlaterFixed in Version 
Summary0006323: ocamlc -i can generate a wrong signature
DescriptionSometimes ocamlc -i generates a wrong signature, and then, either the compiler will give a "helpful" error message by saying something like ... X.t ... is not the same as ... t ..., or it says something like "val x : t is not included in va x : t", which is not helpful at all.
Steps To ReproduceThis generates a rather understandable error:
cat > <<EOF
type t = A

module X =
  type t = B
  let x = A
ocamlc -i > a.mli
ocamlc -c a.mli
ocamlc -c # this one fails but I'm nearly okay with it because it's possible to guess what's wrong from the error message and fix it.

But this gives an error that's very hard to understand, especially when the program is not that small:

cat > <<EOF
type 'a t = B of 'a t list

let rec foo f = function
  | B(v)::tl -> B(foo f v)::foo f tl
  | [] -> []

module DT = struct
  type 'a t = {bar : 'a}
  let p t = foo (fun x -> x) t
ocamlc -i > b.mli
ocamlc -c b.mli
ocamlc -c # this one fails and the error message bothers me a lot because the error message is virtually impossible to understand when the program is fairly larger than this toy example.
Additional InformationI guess that either ocamlc -i should never generate an interface that won't compile, or the error message for the second example (i.e., should be improved.

In the case where it's chosen that it's acceptable for ocamlc -i to generate interfaces that won't compile, I believe it should at least give warnings or provide ways to track down the "generated errors".
TagsNo tags attached.
Attached Files

- Relationships
duplicate of 0004791acknowledged ocamlc -i produces incorrect result 
has duplicate 0007402closedgarrigue "ocamlc -i ..." can generate mli-file that is not compilable 
related to 0006324acknowledged Module aliasing and ability to reference the current and parent modules 

-  Notes
kaustuv (reporter)
2014-02-06 19:15

I've run into this issue numerous times as well. I've stopped naming my types "t" as a result of this and a related issue [1].

I think the compiler should reject a module whose visible values have un-namable types. This augments the current heuristic that the same type name cannot be introduced in the same scope more than once.

[1] functors like Set.Make cannot be instantiated with a module with a carrier type of "t" if "t" is already visible. For some reason, type t = t is taken as a recursive type abbreviation, which breaks a common use case to support a baroque corner case (-rectypes)!
doligez (administrator)
2014-07-16 17:55

ocamlc -i originates as a kind of "verbose" option and was not implemented as a well-thought-out must-work-in-all-cases interface-generation tool.
We might want to turn it into one, but that will probably involve a large amount of work.

- Issue History
Date Modified Username Field Change
2014-02-06 18:59 pw374 New Issue
2014-02-06 19:15 kaustuv Note Added: 0010904
2014-02-19 20:25 doligez Relationship added related to 0006324
2014-05-30 14:14 shinwell Relationship added related to 0006416
2014-05-30 14:16 shinwell Status new => acknowledged
2014-07-16 17:55 doligez Note Added: 0011861
2014-07-16 17:55 doligez Target Version => 4.02.1+dev
2014-09-04 00:25 doligez Target Version 4.02.1+dev => undecided
2014-09-15 09:57 doligez Target Version undecided => 4.03.0+dev / +beta1
2016-03-25 16:02 doligez Target Version 4.03.0+dev / +beta1 => later
2016-11-08 11:16 doligez Relationship added has duplicate 0007402
2017-02-23 16:45 doligez Category OCaml typing => typing
2017-03-14 04:18 garrigue Relationship added duplicate of 0004791
2017-03-14 04:20 garrigue Status acknowledged => closed
2017-03-14 04:20 garrigue Assigned To => garrigue
2017-03-14 04:20 garrigue Resolution open => duplicate
2017-03-14 09:06 garrigue Relationship deleted related to 0006416

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker