Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004791OCamltypingpublic2009-05-15 12:212017-03-23 18:17
Reporterjerhoud 
Assigned To 
PrioritylowSeverityfeatureReproducibilityalways
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version3.10.2 
Target VersionlaterFixed in Version 
Summary0004791: ocamlc -i produces incorrect result
Description> cat a.ml

(* begin of a.ml *)
type t = A
  
module B =
struct
  type t = B
    
  let f A = B
end
(* end of a.ml *)

> ocamlc -i a.ml

type t = A
module B : sig type t = B val f : t -> t end

The type of f is incorrect, it should be something like "val f : A.t -> B.t" except that there seems to be no way of actually writing a correct signature for module B (both A.t and B.t are unbound at this stage).

On the other hand, other definitions using f seem to be typed correctly.

I may admit that there is no way to solve this problem, but ocamlc -i should report an error instead of producing an incorrect result.

TagsNo tags attached.
Attached Files? file icon a.ml [^] (106 bytes) 2009-05-15 12:21 [Show Content]

- Relationships
related to 0007458assignedgarrigue Printing of type aliases in signatures could be improved (with nonrec) 
parent of 0006587resolvedgarrigue #show_module prints types incorrectly 
has duplicate 0006323closedgarrigue ocamlc -i can generate a wrong signature 
has duplicate 0007402closedgarrigue "ocamlc -i ..." can generate mli-file that is not compilable 
related to 0006634acknowledged Type $t is not included in type $t 
related to 0006416confirmed The same string can mean different types in the same error message 
related to 0006654confirmed Destructive substitution on classes produces unrepresentable module type 

-  Notes
(0007496)
garrigue (manager)
2012-06-01 09:42

Scoping of types in signatures is unfortunately a problem with no easy solution.
This is just one of its instances.

Note that unification errors involving several types with the same name result in printing internal ids to distinguish them.
(0011956)
doligez (administrator)
2014-07-31 16:16

FTR, there is one radical solution to this problem: refuse any value whose type cannot be expressed in the current scope. In this example, ocamlc would refuse to compile a.ml, with or without option -i.
(0017633)
garrigue (manager)
2017-03-14 04:15

No good general solution as there could be very strange scoping situations, one just has to fix the signature by hand when possible.
(0017694)
octachron (developer)
2017-03-23 18:17

If printing the correct signature in the general case does seem quite complex, I think that adding a warning for unprintable signature might be worthwhile, see https://github.com/ocaml/ocaml/pull/1120 [^] for a possible implementation.

- Issue History
Date Modified Username Field Change
2009-05-15 12:21 jerhoud New Issue
2009-05-15 12:21 jerhoud File Added: a.ml
2009-05-15 17:09 doligez Status new => acknowledged
2012-06-01 09:42 garrigue Note Added: 0007496
2012-07-11 14:51 doligez Target Version => 4.01.0+dev
2012-07-31 13:36 doligez Target Version 4.01.0+dev => 4.00.1+dev
2012-09-17 14:05 doligez Target Version 4.00.1+dev => 4.01.0+dev
2013-07-24 22:33 doligez Target Version 4.01.0+dev => 4.01.1+dev
2014-05-25 20:20 doligez Target Version 4.01.1+dev => 4.02.0+dev
2014-07-31 16:16 doligez Note Added: 0011956
2014-07-31 16:16 doligez Target Version 4.02.0+dev => 4.03.0+dev / +beta1
2016-03-21 17:16 doligez Target Version 4.03.0+dev / +beta1 => 4.03.1+dev
2017-01-17 08:42 garrigue Relationship added related to 0007458
2017-02-16 14:00 doligez Target Version 4.03.1+dev => undecided
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-02-24 16:37 doligez Priority normal => low
2017-02-24 16:37 doligez Category -OCaml general => typing
2017-02-24 16:37 doligez Target Version undecided => later
2017-03-14 04:15 garrigue Note Added: 0017633
2017-03-14 04:15 garrigue Severity minor => feature
2017-03-14 04:18 garrigue Relationship added has duplicate 0006323
2017-03-14 04:22 garrigue Relationship added has duplicate 0007402
2017-03-14 08:26 garrigue Relationship added related to 0006634
2017-03-14 09:06 garrigue Relationship added related to 0006416
2017-03-14 10:51 garrigue Relationship added related to 0006654
2017-03-14 11:27 garrigue Relationship added parent of 0006587
2017-03-23 18:17 octachron Note Added: 0017694


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker