Repository navigation
Fix editor analysis for declarations in module types, signatures and .resi files - #9332
Conversation
Changelog🐛 Bug fix
Semantic Diff1 commit · Full page Read signature declarations by name in editor analysisfe98bb0 · cknitt + Claude · Nov 19, 2026, 17:04 UTC
Rename modified (a value declared in a module type) module type MT = {
let inMt: int
}
-`let inMt: int` ⇝ `renamed`
+`inMt` ⇝ `renamed`References modified (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
-none
+`sigValue` in `let sigValue: int` of WithSig.S
+`sigValue` in `Sealed.Nested.sigValue`References modified (a module nested in a signature constraint) // SignatureItems.res
module M: {
module Inner: {
let v: int
}
} = {
module Inner = {
let v = 1
}
}
// SignatureItemsUse.res
let v = SignatureItems.M.Inner.v
-`let v: int` (the whole declaration)
+`v` in `let v: int`
+`v` in `SignatureItems.M.Inner.v` in SignatureItemsUse.resReview
|
✅ Compiler benchmarksAllocated wordsIn total: 639,849,023 → 639,848,738 (±0.00%). Generated projects: 629,813,782 → 629,813,711 (±0.00%). None of the 265 benchmarks changed by 0.1% or more. InstructionsIn total: 9,210,478,767 → 9,210,478,767 (±0.00%). None of the 33 benchmarks changed by 0.1% or more. Output sizeIn total: 25,919,386 → 25,919,386 (±0.00%). None of the 13 benchmarks changed by 0.1% or more. Pull request fe98bb0 compared with base 42598c1 in this run. |
b6796a8 to
8ac0a09
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## fix-uri-is-interface #9332 +/- ##
=====================================================
Coverage 82.15% 82.16%
=====================================================
Files 456 456
Lines 65656 65668 +12
=====================================================
+ Hits 53939 53955 +16
+ Misses 11717 11713 -4
🚀 New features to boost your workflow:
|
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-9332 |
|
@codex review |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
8ac0a09 to
39c4de9
Compare
39c4de9 to
7955ee9
Compare
db7c37a to
3192a35
Compare
3192a35 to
d5a1470
Compare
d5a1470 to
e6e856e
Compare
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.
Rename modified (a value declared in a module type):
Example:
module type MT = {
let inMt: int
}
Before (text): renaming inMt to renamed
`let inMt: int` ⇝ `renamed`
After (text): renaming inMt to renamed
`inMt` ⇝ `renamed`
References modified (a value of a module type nested in a module type):
Example:
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
Before (text): references of sigValue in the last line
none
After (text): references of sigValue in the last line
`sigValue` in `let sigValue: int` of WithSig.S
`sigValue` in `Sealed.Nested.sigValue`
References modified (a module nested in a signature constraint):
Example:
// SignatureItems.res
module M: {
module Inner: {
let v: int
}
} = {
module Inner = {
let v = 1
}
}
// SignatureItemsUse.res
let v = SignatureItems.M.Inner.v
Before (text): references of v in M's signature
`let v: int` (the whole declaration)
After (text): references of v in M's signature
`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.
Review: 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.
Review: 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.
Fixes: #9324
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gGbYDy2DBe5YmGdHTL
Signed-off-by: Christoph Knittel <ck@cca.io>
e6e856e to
fe98bb0
Compare
|
@codex review |
1 similar comment
|
@codex review |
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. This causes three bugs:
let x: int, with the new name instead of just the name.With this change, module types and signature constraints written in source are read from the typed tree, which has the location of each name. Nested modules keep their name in the module path.
Tests: new fixtures
SignatureItems.res,SignatureItemsUse.resandSignatureItemsIntf.res/.resi. In the existing snapshotsReferences,DefinitionWithInterface.resand threerescript-tools docsnapshots, locations now point at the name instead of the whole item.Not fixed: renaming a value in a module type does not rename the modules that implement it.
Stacked on #9337.
Fixes #9324
🤖 Generated with Claude Code
https://claude.ai/code/session_01Kbf3gGbYDy2DBe5YmGdHTL