Skip to content

Add support for disc union types fields in LSP

Clarification and motivation

We added support for constructors and record fields in !3042 (merged). However, record fields in disc union types are not supported. For example:

type t = { kind: "First", a : int } | { kind: "Second", b : bool }

function f (x : t) {
  switch (x.kind) {
    case "First": return x.a
    case "Second": return 0
  }
}

All these fields are not visible in LSP (i.e. requests like "go to definition", "hover", "document symbol" etc don't work for them).

Acceptance criteria

  • Record fields in disc union types are visible in scope definitions.
  • LSP can see these definitions and references (including switch on the common field).