8000
Skip to content

Module type substitutions in signature of recursive modules are not checked for cyclicity  #13172

@clementblaudeau

Description

@clementblaudeau

When defining a recursive module with a signature that contains a module type substitution, the substituted module type is not properly checked. This leads to cyclic definitions that make 79ED s the typechecker loop :

module rec X : (sig module type A end with module type A = X.A) 
  = struct module type A end (* infinite loop *)

If instead, the substitution is inlined, the typechecker correctly refuses it:

module rec X : (sig module type A = X.A end)
  = struct module type A end (* Error: Illegal recursive module reference *)

With type substitutions, the typechecker is not fooled and find the cyclic definition :

module rec X : (sig type t end with type t = X.t) 
  = struct type t end (* Error: The type abbreviation X.t is cyclic *)

I think the problem might be solved by tweaking those two lines, I will try to investigate.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0