Skip to content

False detection of self cycle error with an explicit module type #5368

Closed
@cannorin

Description

@cannorin

Version: 9.1.4

Assume we have the following code of name b.res:

module Types : {
  module B : {
    type t = private int
  }
} = {
  module B = {
    type t = private int
  }
}

open Types

module B = {
  open B
  let t : t = Obj.magic(42)
}

This fails with a FAILED: B has a self cycle error despite that this does not contain any dependency to itself.
The open B actually refers to Types.B, but the compiler falsely detects it as a self-reference.

Interestingly, when you remove the explicit module type of the Types module, it compiles correctly:

module Types = {
  module B = {
    type t = private int
  }
}

open Types

module B = {
  open B
  let t : t = Obj.magic(42)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions