Repository navigation
Conversation
Changelog🐛 Bug fix
Semantic Diff1 commit · Full page ✏️ Treat included members as copies of their declarations in editor analysis63fe1e1 · cknitt + Claude · Dec 03, 2026, 20:04 UTC · edited
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. 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
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9331 +/- ##
==========================================
+ Coverage 82.47% 82.59% +0.11%
==========================================
Files 466 468 +2
Lines 66070 66285 +215
==========================================
+ Hits 54493 54746 +253
+ Misses 11577 11539 -38
🚀 New features to boost your workflow:
|
✅ Compiler benchmarksAllocated wordsIn total: 653,172,926 → 653,173,043 (±0.00%). Generated projects: 627,288,369 → 627,288,475 (±0.00%). None of the 265 benchmarks changed by 0.1% or more. InstructionsIn total: 8,966,821,151 → 8,966,821,151 (±0.00%). None of the 33 benchmarks changed by 0.1% or more. Output sizeIn total: 27,449,936 → 27,449,936 (±0.00%). None of the 13 benchmarks changed by 0.1% or more. Pull request 63fe1e1 compared with base 7968a96 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
…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. 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>
3c61679 to
63fe1e1
Compare
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