Repository navigation
Fix editor references for members brought in by include - #9331
Conversation
Changelog🐛 Bug fix
Semantic Diff3 commits · Full page Treat included members as copies of their declarations in editor analysisec1b6e3 · cknitt + Claude · Dec 03, 2026, 20:04 UTC
References modified (include) // Lib.res
module type T = {
type t
}
module Make = (X: T) => {
type shape = Dot | Box(X.t)
}
// Main.res
include Lib.Make({
type t = int
})
let v0 = 0
let v1 = 1
let v2 = 2
module type T = {
type t
}
module F = (X: T) => {
let fv = 1
}
include F({
type t = int
})
let u = fv
// Other.res
let w = Main.v0 + Main.v1
-v0 in Main Main 3:4, Main 0:-1, Main 3:4
-fv in F Main 10:6
+v0 in Main Main 3:4, Other 0:13
+fv in F Main 10:6, Main 15:8
fv after include Main 10:6, Main 15:8References modified (constructor of an included type) // Main.res, with Lib.res as above
include Lib.Make({
type t = int
})
let v0 = 0
let v1 = 1
let dot = Dot
let box = Box(1)
-Dot in Main Main 3:4, Main 0:-1, Main 3:4, Main 5:10
-definition of Box null
+Dot in Main Main 5:10, Lib 4:15
+definition of Box Lib 4:21References modified (include with a shadowed member) module Base = {
type t = A | B
type r = {f: int}
let bv = 1
let other = 2
}
module Over = {
include Base
let other = 3
}
let a = Over.A
let f = (x: Over.r) => x.f
let b = Over.bv + Base.bv
let o = Over.other
-Over.A 1:11, 0:-1, 0:-1, 10:13
-x.f 2:12, 0:-1, 0:-1, 11:25
-Over.bv 3:6, 3:6, 3:6, 12:13
-Over.other 8:6, 8:6, 8:6, 13:13
+Over.A 1:11, 10:13
+x.f 2:12, 11:25
+Over.bv 3:6, 12:13, 12:23
+Over.other 8:6, 13:13References modified (include module type of) // M.res
module Base = {
let bv = 1
}
include Base
// M.resi
module Base: {
let bv: int
}
include module type of Base
-M.resi 1:2 (all of `let bv: int`), M.res 1:6
+M.resi 1:6, M.res 1:6A copy whose original member is found is not a declaration of the including file: it has no definition item and no declaration reference. The original is found from the copy's module path, which names the included module Find References on a value, type or module gathers the original member and all its copies in the file and in the other file of a .res/.resi pair, and the original's references in its own file when it is in another one. Constructors and fields go through their type. The uses that other files record for all of them are collected in one pass over the project, under their paths or under other paths that resolve to them. Go to definition on a constructor or field of a copied type goes to the one it copies. A module that shadows a member it includes gets an implicit constraint to its own signature. Its members, read again from that signature, keep what the structure gave them, so its copies stay copies, and each member is declared once. Constructors and record fields read from a signature (an include, a module type, a functor parameter) get stamps of their own. References at ghost locations, such as those of members read from a signature, are dropped, so there are no Review
Follow each member of another file once, and only members of the file2340a38 · cknitt + Claude · Dec 04, 2026, 11:03 UTC
References modified (converging include chains) // Lib.res
let x = 1
let y = x
// Mid.res
include Lib
// A.res
include Mid
// A.resi
include module type of Lib
// Use.res
let u = A.x
-Use 0:10, Lib 0:4, Lib 1:8, Lib 0:4, Lib 1:8
+Use 0:10, Lib 0:4, Lib 1:8References modified (alias into another file) // Lib.res
let a0 = 0
module Inner = {
let iv = 1
}
// Main.res, where a0 has the stamp that iv has in Lib
include Lib
// Main.resi
module Inner: {
let iv: int
}
// Use.res
let v = Main.Inner.iv
-Use 0:19, Lib 0:4 (a0), Main.resi 1:6
+Use 0:19, Main.resi 1:6Find References remembers the members of other files it has followed, which also bounds the walk. The lookup of a path in a module of another file is one helper. ✨ Gather each family of copies in another file oncebd8c8ca · cknitt + Claude · Dec 04, 2026, 12:55 UTC · new
References modified (two chains into one family) // Lib.res
module Base = {
let x = 1
}
include Base
let y = x
// A.res
include Lib
// A.resi
include module type of Lib.Base
// Use.res
let u = A.x
-Use 0:10, Lib 4:8, Lib 1:6, Lib 4:8, Lib 1:6
+Use 0:10, Lib 4:8, Lib 1:6 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9331 +/- ##
==========================================
+ Coverage 82.59% 82.67% +0.08%
==========================================
Files 468 469 +1
Lines 66296 66553 +257
==========================================
+ Hits 54754 55023 +269
+ Misses 11542 11530 -12
🚀 New features to boost your workflow:
|
✅ Compiler benchmarksAllocated wordsIn total: 656,848,396 → 656,848,245 (±0.00%). Generated projects: 629,104,154 → 629,104,943 (±0.00%). None of the 265 benchmarks changed by 0.1% or more. InstructionsIn total: 8,978,951,125 → 8,978,951,125 (±0.00%). None of the 33 benchmarks changed by 0.1% or more. Output sizeIn total: 27,578,382 → 27,578,382 (±0.00%). None of the 13 benchmarks changed by 0.1% or more. Pull request bd8c8ca compared with base f28cde7 in this run. |
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-9331 |
|
@codex review |
Codex Review Summary: ✅ CompletedThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 73f322a215
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
73f322a to
610362c
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 610362c9da
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
610362c to
5bc3c31
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5bc3c3186f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
5bc3c31 to
16f3ab8
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! 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". |
ab17d40 to
f00fc1e
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. 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". |
bfe8b5e to
8745394
Compare
8745394 to
74c7fef
Compare
3c61679 to
63fe1e1
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 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". |
…ysis
Why:
An `include` copies the members of a module under new stamps, at the
positions of the original declarations. Analysis registers each copy
as a declaration of the including file, so Find References on a member
splits into the declaration with its direct uses and the uses of the
copy (`fv` below).
Constructors and record fields keep their identifiers through an
include. When they come from another file's compilation, their stamps
can equal stamps of values in the including file (`Dot` and `Box`
below have the stamps of `v0` and `v1`). Find References on such a
value then lists wrong and `0:-1` locations and misses its uses in
other files.
References modified (include):
Example:
// Lib.res
module type T = {
type t
}
module Make = (X: T) => {
type shape = Dot | Box(X.t)
}
// Main.res
include Lib.Make({
type t = int
})
let v0 = 0
let v1 = 1
let v2 = 2
module type T = {
type t
}
module F = (X: T) => {
let fv = 1
}
include F({
type t = int
})
let u = fv
// Other.res
let w = Main.v0 + Main.v1
Before (text): line:column, from 0
v0 in Main Main 3:4, Main 0:-1, Main 3:4
fv in F Main 10:6
fv after include Main 10:6, Main 15:8
After (text):
v0 in Main Main 3:4, Other 0:13
fv in F Main 10:6, Main 15:8
fv after include Main 10:6, Main 15:8
References modified (constructor of an included type):
Example:
// Main.res, with Lib.res as above
include Lib.Make({
type t = int
})
let v0 = 0
let v1 = 1
let dot = Dot
let box = Box(1)
Before (text): line:column, from 0
Dot in Main Main 3:4, Main 0:-1, Main 3:4, Main 5:10
definition of Box null
After (text):
Dot in Main Main 5:10, Lib 4:15
definition of Box Lib 4:21
References modified (include with a shadowed member):
Example:
module Base = {
type t = A | B
type r = {f: int}
let bv = 1
let other = 2
}
module Over = {
include Base
let other = 3
}
let a = Over.A
let f = (x: Over.r) => x.f
let b = Over.bv + Base.bv
let o = Over.other
Before (text): line:column, from 0
Over.A 1:11, 0:-1, 0:-1, 10:13
x.f 2:12, 0:-1, 0:-1, 11:25
Over.bv 3:6, 3:6, 3:6, 12:13
Over.other 8:6, 8:6, 8:6, 13:13
After (text):
Over.A 1:11, 10:13
x.f 2:12, 11:25
Over.bv 3:6, 12:13, 12:23
Over.other 8:6, 13:13
References modified (include module type of):
Example:
// M.res
module Base = {
let bv = 1
}
include Base
// M.resi
module Base: {
let bv: int
}
include module type of Base
Before (text): bv in Base, line:column, from 0
M.resi 1:2 (all of `let bv: int`), M.res 1:6
After (text):
M.resi 1:6, M.res 1:6
A copy whose original member is found is not a declaration of the
including file: it has no definition item and no declaration reference.
The original is found from the copy's module path, which names the
included module `source` and the modules a nested copy sits in: the copy of
`x` in a nested `Inner` resolves to `source.Inner.x`. Other files reach
that copy under its full path, such as `Main.Inner.x`.
Find References on a value, type or module gathers the original member and
all its copies in the file and in the other file of a .res/.resi pair, and
the original's references in its own file when it is in another one.
Constructors and fields go through their type. The uses that other files
record for all of them are collected in one pass over the project, under
their paths or under other paths that resolve to them. Go to definition on a constructor or field of a copied
type goes to the one it copies.
A module that shadows a member it includes gets an implicit constraint to
its own signature. Its members, read again from that signature, keep what
the structure gave them, so its copies stay copies, and each member is
declared once. `include module type of M` in a signature is an include of
`M`.
Constructors and record fields read from a signature (an include, a module
type, a functor parameter) get stamps of their own. References at ghost
locations, such as those of members read from a signature, are dropped, so
there are no `0:-1` entries.
Review: Why fresh stamps for constructors and fields of signatures? An
include or a module type keeps their identifiers, and a signature from
another file brings that compilation's stamps, which can equal stamps of
this one. Fresh stamps avoid that wherever the signature comes from, also
for `include unpack(...)` and for a functor parameter, where no original
can be resolved. They count down from -2, because 0 marks a persistent
identifier and -1 a hidden one. The numbering restarts for each file, so
reading a file twice gives the same stamps.
Review: What does the project scan cost? Find References reads each file of
the project, and the other file of a .res/.resi pair, once per query,
whatever the number of copies.
Review: Why does the Hover snapshot change? `@react.component` adds a second
`make`, so the module was read twice and `x` was declared twice. With one
declaration, the JSX heuristic no longer runs; the hover text is the same.
Review: What is not found? From the declaration in another file, uses
through the including file's copy, such as `Main.Dot` or `Main.made`, are
not found, as on master. Constructors and fields of a module type `S` used
through another module type that includes it, as with
`module type S2 = { include S }`, `module M: S` and a parameter `X: S2`,
are not connected. On master they were, only through shared stamps and
with `0:-1` entries. Values already behave this way.
Fixes: #9323
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gGbYDy2DBe5YmGdHTL
Claude-Session: https://claude.ai/code/session_01Kbf3gGgQuXy1xmZbjATZsB
Signed-off-by: Christoph Knittel <ck@cca.io>
63fe1e1 to
ec1b6e3
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ec1b6e3e6b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
Why:
When a .res and its .resi reach the same declaration through different
includes, Find References walked that declaration twice, listed its
locations twice, and rename made two identical edits for each, which
editors can reject. And a path into the other file of a module could
resolve through an alias into a third file, whose stamp was then taken
for a member of the other file: Find References and rename reached an
unrelated declaration.
References modified (converging include chains):
Example:
// Lib.res
let x = 1
let y = x
// Mid.res
include Lib
// A.res
include Mid
// A.resi
include module type of Lib
// Use.res
let u = A.x
Before (text): A.x in Use, line:column, from 0
Use 0:10, Lib 0:4, Lib 1:8, Lib 0:4, Lib 1:8
After (text):
Use 0:10, Lib 0:4, Lib 1:8
References modified (alias into another file):
Example:
// Lib.res
let a0 = 0
module Inner = {
let iv = 1
}
// Main.res, where a0 has the stamp that iv has in Lib
include Lib
// Main.resi
module Inner: {
let iv: int
}
// Use.res
let v = Main.Inner.iv
Before (text): Main.Inner.iv in Use, line:column, from 0
Use 0:19, Lib 0:4 (a0), Main.resi 1:6
After (text):
Use 0:19, Main.resi 1:6
Find References remembers the members of other files it has followed, which
also bounds the walk. The lookup of a path in a module of another file is
one helper.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gGgQuXy1xmZbjATZsB
Signed-off-by: Christoph Knittel <ck@cca.io>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2340a383a0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
Why:
Find References remembered only the member of another file it followed,
but gathers that member's whole family of copies. A second include chain
to another member of the family gathered it again, so locations and
rename edits came twice.
References modified (two chains into one family):
Example:
// Lib.res
module Base = {
let x = 1
}
include Base
let y = x
// A.res
include Lib
// A.resi
include module type of Lib.Base
// Use.res
let u = A.x
Before (text): A.x in Use, line:column, from 0
Use 0:10, Lib 4:8, Lib 1:6, Lib 4:8, Lib 1:6
After (text):
Use 0:10, Lib 4:8, Lib 1:6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gGgQuXy1xmZbjATZsB
Signed-off-by: Christoph Knittel <ck@cca.io>
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! 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". |
Editor analysis treats each member copied by an
includeas a declaration of its own, at the position of the original declaration. This causes two problems:0:-1locations, and misses uses in other files.With this change:
.res/.resipair, and, for a member included from another file, in that file too.include module type of Min a signature.0:-1entries.New tests:
IncludeDeclarations.res,IncludeDeclarationsLib.resandIncludeDeclarationsUse.rescover colliding stamps, includes of local functors and modules, nested includes, includes inside a module, several copies of one member, constructors and fields from another file's functor, and uses from another file.IncludeDeclarationsParam.res,IncludeDeclarationsSig.resandIncludeDeclarationsUnpack.rescoverincludeof a functor parameter andinclude unpack(...).IncludeDeclarationsOverride.rescovers includes with a shadowed member, also from another file.IncludeDeclarationsIntf.res(i)withIncludeDeclarationsIntfUse.res, andIncludeDeclarationsTypeOf.res(i), cover a module with an interface andinclude module type of.Not found: uses through the including file's path when Find References starts from the original declaration in another file, and constructors and fields of a module type used through another module type that includes it.
Fixes #9323
🤖 Generated with Claude Code
https://claude.ai/code/session_01Kbf3gGbYDy2DBe5YmGdHTL