Semantic Diff

#9332 Fix editor analysis for declarations in module types, signatures and .resi files

1 commit

8aa74ec3f8993d2a5b051f68e95b84884b6e1ac9..pr-9332

fe98bb0fe · cknitt + Claude · Nov 19, 2026, 17:04 UTC

Read signature declarations by name in editor analysis

Why

Editor analysis reads the declarations in module types and signature constraints from their types. A type only knows where a whole item is, not where its name is. So rename replaces a value's whole declaration instead of its name, module types nested in a module type are not registered, and modules nested in a signature constraint lose their name in the module path, which hides their uses in other files.

Module types and signature constraints written in source are now read from the typed tree, which has the location of each name. Nested modules keep their name in the module path.

modifiedRename a value declared in a module type

module type MT = {  let inMt: int}
text
Before renaming inMt to renamed
After renaming inMt to renamed
`let inMt: int` ⇝ `renamed``inMt` ⇝ `renamed`

modifiedReferences a value of a module type nested in a module type

module type WithSig = {  module type S = {    let sigValue: int  }  module Nested: S}module Sealed: WithSig = {  module type S = {    let sigValue: int  }  module Nested = {    let sigValue = 1  }}let sv = Sealed.Nested.sigValue
text
Before references of sigValue in the last line
After references of sigValue in the last line
none `sigValue` in `let sigValue: int` of WithSig.S`sigValue` in `Sealed.Nested.sigValue`

modifiedReferences a module nested in a signature constraint

// SignatureItems.resmodule M: {  module Inner: {    let v: int  }} = {  module Inner = {    let v = 1  }}// SignatureItemsUse.reslet v = SignatureItems.M.Inner.v
text
Before references of v in M's signature
After references of v in M's signature
`let v: int` (the whole declaration) `v` in `let v: int``v` in `SignatureItems.M.Inner.v` in SignatureItemsUse.res

Review

  • Which existing snapshots change? References, DefinitionWithInterface.res and three rescript-tools doc snapshots (DocExtraction2, DocExtractionRes): their locations now point at a value's name, or at its let line instead of the doc comment above it.
  • Which signatures are still read from types? Signatures that have no source: those of include, module type of, with constraints and .cmi files. Their values still get the whole item as location; the types have nothing better.
  • What does not change? Module types copied by an include stay unregistered, and renaming a value in a module type still does not rename the modules that implement it.