Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006485OCamltypingpublic2014-07-14 10:062017-03-11 16:28
Reporterdim 
Assigned Togarrigue 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.01.0 
Target VersionundecidedFixed 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 0006011assignedgarrigue Signatures with private types can make modules less constrained 
has duplicate 0006882resolvedgarrigue Apparently valid program rejected by the typer 

-  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.
(0017627)
octachron (developer)
2017-03-11 16:28

It seems that this specific example was fixed by the incremental weakening of module alias (e75745511527fb7266) patch in OCaml 4.03. Since there is an open duplicate issue expliciting the underlying cause of both issues, I am marking this issue as resolved.

- 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 => 4.02.2+dev / +rc1
2015-05-11 22:51 lpw25 Target Version 4.02.2+dev / +rc1 => 4.03.0+dev / +beta1
2015-06-03 02:23 garrigue Relationship added has duplicate 0006882
2016-04-06 13:56 doligez Target Version 4.03.0+dev / +beta1 => 4.03.1+dev
2017-02-16 14:01 doligez Target Version 4.03.1+dev => undecided
2017-02-23 16:45 doligez Category OCaml typing => typing
2017-03-11 16:28 octachron Note Added: 0017627
2017-03-11 16:28 octachron Status assigned => resolved
2017-03-11 16:28 octachron Resolution open => fixed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker