Skip to content

Create interface breaks types of applied functors and include F(...) #9065

Closed

Description

@cknitt

Create interface (rescript-editor-analysis createInterface, used by the editor's "Create interface file" command) copies each type declaration verbatim from the source file at the declaration's location. A type of an applied functor or of an included module is located in the functor's body, possibly in another file, so the generated .resi gets either the unsubstituted body type or whatever lines of the current file happen to be at that position.

Same file:

module type Ord = {
  type t
  let compare: (t, t) => int
}
module MakeSet = (O: Ord) => {
  type t = array<O.t>
  let add = (s: t, x: O.t) => s->Array.concat([x])
}
module IntSet = MakeSet({
  type t = int
  let compare = (a: int, b) => a - b
})
module IntSet: {
  type t = array<O.t>   // O is not in scope; expected array<int>
  let add: (t, int) => array<int>
}

Functor from another file (AdvancedTypes.MakeSet as above):

module StrSet = AdvancedTypes.MakeSet({
  type t = string
  let compare = (a: string, b) => a < b ? -1 : a > b ? 1 : 0
})

include AdvancedTypes.MakeSet({
  type t = float
  let compare = (a: float, b) => a < b ? -1 : a > b ? 1 : 0
})
module StrSet: {

  let add: (t, string) => array<string>
}

let add: (t, float) => array<float>

type t is replaced by an empty line (the lines of the functor's declaration don't exist in this file), so the interface doesn't compile. The compiler's own signature is correct (type t = array<int> etc.).

Activity

  1. added theissue type on Oct 27, 2026
  2. added 2 commits that reference this issue on Oct 28, 2026
    a064592
    52ae045
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions