Skip to content
Permalink
Browse files

PR#7787: fix module type of and recursive modules interaction

Mta_absent and Mta_present aliases should be compiled differently.
  • Loading branch information...
trefis committed Apr 27, 2018
1 parent 832a3ec commit 1eabf70fa06b509971f7f31605b7b7c30f3d70ca
Showing with 52 additions and 4 deletions.
  1. +3 −2 Changes
  2. +3 −2 bytecomp/translmod.ml
  3. +1 −0 testsuite/tests/typing-modules/ocamltests
  4. +45 −0 testsuite/tests/typing-modules/pr7787.ml
@@ -114,9 +114,10 @@ OCaml 4.07
- GPR#1628: Treat reraise and raise_notrace as nonexpansive.
(Leo White, review by Alain Frisch)

* GPR#1652: Don't remove module aliases in `module type of` and `with module`.
* GPR#1652, MPR#7787, GPR#1743: Don't remove module aliases in `module type of`
and `with module`.
The old behaviour can be obtained using the `[@remove_aliases]` attribute.
(Leo White, review by Jacques Garrigue)
(Leo White and Thomas Refis, review by Jacques Garrigue)

### Standard library:

@@ -199,9 +199,10 @@ let undefined_location loc =
let init_shape modl =
let rec init_shape_mod env mty =
match Mtype.scrape env mty with
Mty_ident _ ->
Mty_ident _
| Mty_alias (Mta_present, _) ->
raise Not_found
| Mty_alias _ ->
| Mty_alias (Mta_absent, _) ->
Const_block (1, [Const_pointer 0])
| Mty_signature sg ->
Const_block(0, [Const_block(0, init_shape_struct env sg)])
@@ -6,6 +6,7 @@ pr5911.ml
pr6394.ml
pr7207.ml
pr7348.ml
pr7787.ml
printing.ml
recursive.ml
Test.ml
@@ -0,0 +1,45 @@
(* TEST
* expect
*)

module O (T : sig
module N : sig
val foo : int -> int
end
end) = struct
open T

let go () =
N.foo 42 (* finding N (from T) goes wrong *)
end

module T = struct
module N = struct
let foo x = x + 3
end
end;;
[%%expect{|
module O :
functor (T : sig module N : sig val foo : int -> int end end) ->
sig val go : unit -> int end
module T : sig module N : sig val foo : int -> int end end
|}]

(* Incidentally, M isn't used in T2, but it doesn't seem to fail if
it's just "module M" and "module T2" separately *)
module rec M : sig
val go : unit -> int
end = O (T2)
and T2 : sig
include module type of struct include T end
end = struct
include T
end;;
[%%expect{|
module rec M : sig val go : unit -> int end
and T2 : sig module N = T.N end
|}]

let () = ignore (M.go ())
[%%expect{|
|}]

0 comments on commit 1eabf70

Please sign in to comment.
You can’t perform that action at this time.