Skip to content

False "unused open" warning #6752

Closed
Closed
@cwstra

Description

@cwstra

Examples run in the playground, with v11.1.0.

Consider the following snippet:

module M = {
  type t = {
    id: string,
    value?: int,
  }
}

open M
let value = [{id: "id"}]

Pasting this example code into the playground successfully compiles, but with a warning:

[W] Line 8, column 0:
unused open M.

Yet, if we remove this 'unused' open,

module M = {
  type t = {
    id: string,
    value?: int,
  }
}

let value = [{id: "id"}]

we get a compiler error (as expected by module scoping)

[E] Line 8, column 14:
The record field id can't be found.

Interestingly, the warning disappears if remove the value field:

module M = {
  type t = {
    id: string,
  }
}

open M
let value = [{id: "id"}]

or pass a value for it:

module M = {
  type t = {
    id: string,
    value?: int
  }
}

open M
let value = [{id: "id",  value: 1}]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions