Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

private lost after rebinding module #6485

Closed
vicuna opened this issue Jul 14, 2014 · 2 comments
Closed

private lost after rebinding module #6485

vicuna opened this issue Jul 14, 2014 · 2 comments
Assignees

Comments

@vicuna
Copy link

vicuna commented Jul 14, 2014

Original bug ID: 6485
Reporter: @diml
Assigned to: @garrigue
Status: resolved (set by @Octachron on 2017-03-11T15:28:05Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.01.0
Target version: undecided
Category: typing
Has duplicate: #6882
Related to: #6011
Monitored by: @lpw25 @hcarty

Bug description

Tested 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)

@vicuna
Copy link
Author

vicuna commented Jul 14, 2014

Comment author: @gasche

Note that, as a workaround,

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

appears to avoid the dropped-equation problem.

@vicuna
Copy link
Author

vicuna commented Mar 11, 2017

Comment author: @Octachron

It seems that this specific example was fixed by the incremental weakening of module alias (e757455) 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants