Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006485OCamlOCaml typingpublic2014-07-14 10:062014-09-14 21:46
Reporterdim 
Assigned Togarrigue 
PrioritynormalSeverityminorReproducibilityalways
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version4.01.0 
Target Versionafter-4.02.1Fixed in Version 
Summary0006485: private lost after rebinding module
DescriptionTested with 4.01, 4.02 and trunk.

In the following example, the 'type t = private string' in the result of [String_id.Make] becomes 'type t' after rebinding [String_id]:

module String_id : sig
  module type S = sig
    type t = private string
    val of_string : string -> t
  end

  include S

  module Make (M : sig val module_name : string end) : S
end = struct
  module type S = sig
    type t = private string
    val of_string : string -> t
  end

  module String = struct
    type t = string
  end

  module Make (M : sig val module_name : string end) = struct
    include String

    let of_string s =
      Printf.printf "converting %s\n" M.module_name;
      s
  end

  include Make (struct let module_name = "String_id" end)
end

let () =
  (* this compiles *)
  let foo = String_id.of_string "foo" in
  Printf.printf "foo = %s\n" (foo :> string)

let () =
  (* and this compiles *)
  let module Bar = String_id.Make(struct let module_name="Bar" end) in
  let bar = Bar.of_string "bar" in
  Printf.printf "bar = %s\n" (bar :> string)

let () =
  (* this does not *)
  let module String_id2 = String_id in
  let module Baz = String_id2.Make(struct let module_name="Baz" end) in
  let baz = Baz.of_string "baz" in
  Printf.printf "baz = %s\n" (baz :> string)
TagsNo tags attached.
Attached Files

- Relationships
related to 0006011confirmed Signatures with private types can make modules less constrained 

-  Notes
(0011806)
gasche (developer)
2014-07-14 10:55

Note that, as a workaround,

  let module String_id2 = (String_id : module type of String_id) in

appears to avoid the dropped-equation problem.

- Issue History
Date Modified Username Field Change
2014-07-14 10:06 dim New Issue
2014-07-14 10:53 gasche Relationship added related to 0006011
2014-07-14 10:55 gasche Note Added: 0011806
2014-07-15 10:44 shinwell Assigned To => garrigue
2014-07-15 10:44 shinwell Status new => assigned
2014-07-16 16:57 doligez Target Version => 4.02.1+dev
2014-09-04 00:25 doligez Target Version 4.02.1+dev => undecided
2014-09-14 21:46 doligez Target Version undecided => after-4.02.1


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker