Repository navigation
Conversation
Changelog🐛 Bug fix
Semantic Diff1 commit · Full page ✏️ Find references written through another module path0b6ebf7 · cknitt + Claude · Nov 19, 2026, 06:14 UTC · edited
References modified (functor application used from another file) // Fn.res
module type Ord = {
type t
}
module IntOrd = {
type t = int
}
module MakeSet = (O: Ord) => {
let add = (x: O.t) => [x]
}
module MakeTwo = (A: Ord, B: Ord) => {
let pair = 1
}
module First = MakeTwo(IntOrd)
// Use.res
module S = Fn.MakeSet(Fn.IntOrd)
let s = S.add(1)
module Make = Fn.MakeSet
module Aliased = Make(Fn.IntOrd)
let a = Aliased.add(1)
module Fin = Fn.First(Fn.IntOrd)
let p = Fin.pair
// Far.res
let f = Use.S.add(2)
Fn.res 8:7 let add
Use.res 2:11 S.add
Use.res 5:17 Aliased.add
+Far.res 1:15 Use.S.add
Fn.res 11:7 let pair
+Use.res 7:13 Fin.pair
Fn.res 8:7 let add
Use.res 2:11 S.add
Use.res 5:17 Aliased.add
+Far.res 1:15 Use.S.addRename modified (functor application used from another file)
Fn.res let add ⇝ let plus
Use.res S.add ⇝ S.plus
Use.res Aliased.add ⇝ Aliased.plus
+Far.res Use.S.add ⇝ Use.S.plusReferences modified (value of a namespaced dependency) // NsUtils.res in a dependency with namespace NsDep
module Plain = {
let plain = 1
}
// Main.res
let p = NsDep.NsUtils.Plain.plain
module P = NsDep.NsUtils.Plain
let q = P.plain
-NsUtils.res 2:7 let plain
+NsUtils.res 2:7 let plain
+Main.res 1:29 NsDep.NsUtils.Plain.plain
+Main.res 3:11 P.plainReferences modified (value of a module type, used through a module constrained by it in a .resi): // SignatureItemsIntf.resi
module type S = {
let s: int
}
module N: S
// SignatureItemsUse.res
let s = SignatureItemsIntf.N.s
-SignatureItemsIntf.res 2:7 let s
-SignatureItemsIntf.resi 2:7 let s
+SignatureItemsUse.res 4:30 SignatureItemsIntf.N.s
+SignatureItemsIntf.res 2:7 let s
+SignatureItemsIntf.resi 2:7 let sReview
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9329 +/- ##
==========================================
+ Coverage 82.54% 82.55% +0.01%
==========================================
Files 469 469
Lines 66224 66245 +21
==========================================
+ Hits 54666 54690 +24
+ Misses 11558 11555 -3
🚀 New features to boost your workflow:
|
✅ Compiler benchmarksAllocated wordsIn total: 653,178,293 → 653,178,136 (±0.00%). Generated projects: 627,033,836 → 627,034,031 (±0.00%). None of the 265 benchmarks changed by 0.1% or more. InstructionsIn total: 8,963,760,301 → 8,963,760,301 (±0.00%). None of the 33 benchmarks changed by 0.1% or more. Output sizeIn total: 27,441,259 → 27,441,259 (±0.00%). None of the 13 benchmarks changed by 0.1% or more. Pull request 0b6ebf7 compared with base 0a686a9 in this run. |
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
@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. |
|
Codex Review: Didn't find any major issues. Breezy! 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". |
0d4b271 to
4f7a8e1
Compare
4f7a8e1 to
3263625
Compare
3263625 to
a9d05e5
Compare
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-9329 |
6dfad2a to
b14c9d4
Compare
068e9c8 to
c0d0f9d
Compare
Why:
A use in another file is recorded under the path it is written with,
such as `Use.S.add` for a functor application `S` in Use.res. Find
References looks only under the declaration's own path
(`Fn.MakeSet.add`), so it misses uses through the file that applies a
functor, through a partial application, and uses of a namespaced
dependency's values. Rename leaves these uses unchanged, and the code
no longer compiles.
Find References now also resolves the recorded paths that end in the
declaration's name, and keeps those that lead to the declaration or
to its .res/.resi counterpart at the same path.
References modified (functor application used from another file):
Example:
// Fn.res
module type Ord = {
type t
}
module IntOrd = {
type t = int
}
module MakeSet = (O: Ord) => {
let add = (x: O.t) => [x]
}
module MakeTwo = (A: Ord, B: Ord) => {
let pair = 1
}
module First = MakeTwo(IntOrd)
// Use.res
module S = Fn.MakeSet(Fn.IntOrd)
let s = S.add(1)
module Make = Fn.MakeSet
module Aliased = Make(Fn.IntOrd)
let a = Aliased.add(1)
module Fin = Fn.First(Fn.IntOrd)
let p = Fin.pair
// Far.res
let f = Use.S.add(2)
Before (text): 1-based line:column, references of add in Fn.res
Fn.res 8:7 let add
Use.res 2:11 S.add
Use.res 5:17 Aliased.add
After (text): 1-based line:column, references of add in Fn.res
Fn.res 8:7 let add
Use.res 2:11 S.add
Use.res 5:17 Aliased.add
Far.res 1:15 Use.S.add
Before (text): 1-based line:column, references of pair in Fn.res
Fn.res 11:7 let pair
After (text): 1-based line:column, references of pair in Fn.res
Fn.res 11:7 let pair
Use.res 7:13 Fin.pair
Before (text): 1-based line:column, references of Use.S.add in Far.res
Fn.res 8:7 let add
Use.res 2:11 S.add
Use.res 5:17 Aliased.add
After (text): 1-based line:column, references of Use.S.add in Far.res
Fn.res 8:7 let add
Use.res 2:11 S.add
Use.res 5:17 Aliased.add
Far.res 1:15 Use.S.add
Rename modified (functor application used from another file):
Before (text): rename Use.S.add in Far.res to plus
Fn.res let add ⇝ let plus
Use.res S.add ⇝ S.plus
Use.res Aliased.add ⇝ Aliased.plus
After (text): rename Use.S.add in Far.res to plus
Fn.res let add ⇝ let plus
Use.res S.add ⇝ S.plus
Use.res Aliased.add ⇝ Aliased.plus
Far.res Use.S.add ⇝ Use.S.plus
References modified (value of a namespaced dependency):
Example:
// NsUtils.res in a dependency with namespace NsDep
module Plain = {
let plain = 1
}
// Main.res
let p = NsDep.NsUtils.Plain.plain
module P = NsDep.NsUtils.Plain
let q = P.plain
Before (text): 1-based line:column, references of plain in Main.res
NsUtils.res 2:7 let plain
After (text): 1-based line:column, references of plain in Main.res
NsUtils.res 2:7 let plain
Main.res 1:29 NsDep.NsUtils.Plain.plain
Main.res 3:11 P.plain
References modified (value of a module type, used through a module
constrained by it in a .resi):
Example:
// SignatureItemsIntf.resi
module type S = {
let s: int
}
module N: S
// SignatureItemsUse.res
let s = SignatureItemsIntf.N.s
Before (text): 1-based line:column, references of s in SignatureItemsIntf.resi
SignatureItemsIntf.res 2:7 let s
SignatureItemsIntf.resi 2:7 let s
After (text): 1-based line:column, references of s in SignatureItemsIntf.resi
SignatureItemsUse.res 4:30 SignatureItemsIntf.N.s
SignatureItemsIntf.res 2:7 let s
SignatureItemsIntf.resi 2:7 let s
Review: Why not record each use under its declaration's key? Recording
happens per file, without access to the other files a path goes through.
Resolving at search time needs no change to the recorded data.
Review: Why only a counterpart at the same path? With `module N: S` in
the .resi, the counterpart of `N.s` in the .res is `S.s` in the .resi.
Other modules share `S.s`: uses of `I.M.s` for `module M: S` resolve to
it too. Keeping them would list `I.M.s` as a reference of `N.s`, and
Rename would change it.
Review: Does this slow down Find References on large projects? Only
recorded paths that end in the declaration's name are resolved, each
distinct path once per search. Resolving loads the referenced module
through the analysis cache, so the first search in a session pays for
loading these modules once. On 400 files that all export `t`, `make` and
`map`, three searches take 0.42 s against 0.16 s before. After that, a
search costs the same as before, about 15 ms.
Review: Why keep the exact match on the declaration's own path? It is
the common case and needs no resolution, and it keeps every result the
old search found.
Fixes: #9321
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gGUP7SAjW77BvdfhQD
Signed-off-by: Christoph Knittel <ck@cca.io>
c0d0f9d to
0b6ebf7
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". |
A use in another file is recorded under the path it is written with. Find References looks only under the declaration's own path, so it misses some uses:
Use.S.add)Fn.First(Fn.IntOrd))Rename leaves these uses unchanged, and the code no longer compiles.
With this change, Find References also resolves the recorded paths that end in the declaration's name, and keeps those that lead to the declaration. It also keeps those that lead to the declaration's
.res/.resicounterpart, if that counterpart sits at the same path. Withmodule N: Sin the.resi, the counterpart ofN.sis the module type'sS.s. Other modules constrained bySshare it, so uses that lead there are not uses ofN.s.Cost. Each path is resolved once per search. Resolving loads the referenced module through the analysis cache, so the first search in a session loads those modules once. On 400 files that all export
t,makeandmap, three searches take 0.42 s against 0.16 s before. After that, a search costs the same as before.Tests.
PathRefs.res,PathRefsUse.resandPathRefsFar.rescover references and rename through a functor application in another file, a functor alias, a partial application and a module alias, for values, types, record fields and constructors. They also check that a same-named value in a sibling module is not found.PathRefsIntf.res/.resichecks that a module constrained by a module type in the.residoesn't pick up a sibling's uses. A new namespaced dependency intests-sourcedirs-dependencycovers a namespaced dependency's values, written directly and through a module alias.Not covered here. These problems already exist on master:
.resiwrites out a functor application's signature, uses through it are still missed (Find References misses uses of a functor application whose .resi writes out the signature #9508)..resifunctor signature edits the wholeletline (Rename in a .resi functor signature replaces the whole let line #9507).includeare Editor analysis registers included members as separate declarations #9323 (Fix editor references for members brought in by include #9331).Fixes #9321
🤖 Generated with Claude Code
https://claude.ai/code/session_01Kbf3gGUP7SAjW77BvdfhQD