Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006528OCamlOCaml typingpublic2014-08-30 01:012014-09-15 15:22
Assigned To 
PlatformOSOS Version
Product Version4.01.0 
Target Version4.02.2+devFixed in Version 
Summary0006528: type constraints alter signatures in unusual ways
DescriptionI'm not sure exactly what to call this (or if this is in fact a bug) but the following two compilation errors surprised me and seem related: In the first, a value is annotated as having a type exactly as it appears in the signature. That type-checks, but the module still fails to compile.

$ rlwrap ocaml
        OCaml version 4.01.0

# module M : sig
    type 'a t constraint 'a = [< `Foo of _]
    val create : 'a -> 'a t
    end = struct
    type 'a t = 'a constraint 'a = [< `Foo of _]
    let create : 'a. 'a -> 'a t = fun x -> x
Error: Signature mismatch:
       Values do not match:
         val create : ([< `Foo of 'b ] as 'a) -> 'a t
       is not included in
         val create : ([< `Foo of 'b & 'c ] as 'a) -> 'a t

In the second, you are not allowed to replace one type constraints with the same type and the same constraints:

$ rlwrap ocaml
        OCaml version 4.01.0

# module type S = sig type 'a t constraint 'a = [< `Foo of _] end;;
module type S = sig type 'a t constraint 'a = [< `Foo of 'b ] end
# module type S' = sig include S include S with type 'a t := 'a t end;;
Error: In this `with' constraint, the new definition of t
       does not match its original definition in the constrained signature:
       Type declarations do not match:
         type 'a t = 'a t constraint 'a = [< `Foo of 'b & 'c & 'd ]
       is not included in
         type 'a t constraint 'a = [< `Foo of 'b ]
       Their constraints differ.

(Obviously, in that example, in real life it wouldn't be the same signature twice but two different signatures still having the same constraint on their type.)
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2014-08-30 01:01 mkoconnor New Issue
2014-09-15 15:22 doligez Status new => acknowledged
2014-09-15 15:22 doligez Target Version => 4.02.2+dev

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker