Skip to content

Commit ac84b3e

Browse files
author
Roman Leshchinskiy
committed
Recursive module test + location fix
1 parent a124a9f commit ac84b3e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

ocaml/testsuite/tests/typing-modules/strengthening.ml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,14 @@ module Remove_aliases :
340340
end
341341
end
342342
|}]
343+
344+
module Recursive = struct
345+
module rec M : sig end with N = N
346+
and N : sig end = struct end
347+
end
348+
[%%expect{|
349+
Line 2, characters 30-31:
350+
2 | module rec M : sig end with N = N
351+
^
352+
Error: Illegal recursive module reference
353+
|}]

ocaml/typing/typemod.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,8 +911,10 @@ and approx_modtype_jane_syntax env = function
911911
| Jane_syntax.Module_type.Jmty_strengthen { mty = smty; mod_id } ->
912912
let mty = approx_modtype env smty in
913913
let path =
914+
(* CR-someday: potentially improve error message for strengthening with
915+
a mutually recursive module. *)
914916
Env.lookup_module_path ~use:false ~load:false
915-
~loc:smty.pmty_loc mod_id.txt env
917+
~loc:mod_id.loc mod_id.txt env
916918
in
917919
let aliasable = (not (Env.is_functor_arg path env)) in
918920
Mty_strengthen (mty, path, Aliasability.aliasable aliasable)

0 commit comments

Comments
 (0)