-
Notifications
You must be signed in to change notification settings - Fork 473
Closed
Description
Overview
Go-to definition fails whenever a module alias is involved. Minimal repro:
module Base = {
let value = 1
module Nested = { let value = 42 }
}
module Alias = {
module B = Base
}
let x = Alias.B.value
let y = Alias.B.Nested.valueRunning the analysis binary with the cursor on Alias.B.value:
./_build/install/default/bin/rescript-editor-analysis definition /tmp/self_alias.res 8 16
Expected: jump to Base.value. Actual: returns null, so editors stay put.
Stdlib impact
packages/@rescript/runtime/Stdlib.res exposes aliases exactly like this (e.g. module List = Stdlib_List), and navigating on List.map hits the same path and lands at (0,0).
Details
.cmtmetadata still contains the correct spans (Stdlib_List.cmtshowsValue map (402,04--402,07)), so location info is present.- Instrumented
analysis/src/Commands.mlandanalysis/src/References.ml. The alias case produceslocItem=… LModule GlobalReference.resolveModuleReferencetakes theGlobalModbranch (resolveModuleReference GlobalMod Stdlib_List), which yields(file, None). resolveModuleDefinitionthen returnsUri.toTopLevelLoc, so the emitted range is(0,0)even thoughdeclaredForLocalready carries the real location.- The same behaviour reproduces outside the stdlib with the self-contained example above (e.g.
Alias.B.valuereturnsnull).
Ask
Teach References.definition (or its resolver) to follow module aliases through to the underlying declaration so both stdlib and user-defined aliases resolve to the actual source location.
Metadata
Metadata
Assignees
Labels
No labels