Narrow overload-error and symbol-use ranges to terminal identifier#19505
Narrow overload-error and symbol-use ranges to terminal identifier#19505
Conversation
|
@copilot : Try again |
|
@copilot : Try again. |
|
@copilot Try again |
Implemented the fix in commit aa4c1a9. The For |
aa4c1a9 to
7d2f1e9
Compare
❗ Release notes required
|
2751d6e to
47b948d
Compare
a5ac31e to
fc504b7
Compare
bfeba1a to
e89bb2d
Compare
Addresses reviewer feedback on PR #19505: - r3058446895 / r3058471629: compute narrow ident range in name resolution so diagnostics and tooling (Find Usages, symbol highlight, FSharpSymbolUse) report on the item name rather than the full long-identifier path. Approach: ComputeItemRange now returns (itemRange, itemIdentRange): - itemRange (wide, unchanged) flows into typed-tree construction, sequence points, and the delay-rest continuation. Structural ranges and the debug experience are untouched. - itemIdentRange (narrow, terminal ident) is consumed only by the CallMethodGroupNameResolutionSink / CallNameResolutionSink calls and RegisterUnionCaseTesterForProperty. This fixes #3920 at the source. The PR #19505 post-hoc trim for FS0041 'No overloads match' is retained because it narrows the overload-resolution diagnostic via column arithmetic and is orthogonal to the sink narrowing. FindReferences test expectations updated for 7 cases to reflect the newly-correct narrow symbol-use ranges. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
09db23f to
18ae276
Compare
Addresses reviewer feedback on PR #19505: - r3058446895 / r3058471629: compute narrow ident range in name resolution so diagnostics and tooling (Find Usages, symbol highlight, FSharpSymbolUse) report on the item name rather than the full long-identifier path. Approach: ComputeItemRange now returns (itemRange, itemIdentRange): - itemRange (wide, unchanged) flows into typed-tree construction, sequence points, and the delay-rest continuation. Structural ranges and the debug experience are untouched. - itemIdentRange (narrow, terminal ident) is consumed only by the CallMethodGroupNameResolutionSink / CallNameResolutionSink calls and RegisterUnionCaseTesterForProperty. This fixes #3920 at the source. The PR #19505 post-hoc trim for FS0041 'No overloads match' is retained because it narrows the overload-resolution diagnostic via column arithmetic and is orthogonal to the sink narrowing. FindReferences test expectations updated for 7 cases to reflect the newly-correct narrow symbol-use ranges. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…14284, #3920) Narrow the FS0041 'No overloads match' error range from the whole expression to just the method name. For T.Instance.Method(""), the error now covers only 'Method' instead of 'T.Instance.Method("")'. Also narrow name-resolution sink ranges (used by Find Usages, symbol highlight, and semantic classification) to the terminal identifier of a dotted long identifier instead of the whole object-expression path. Changes: - NameResolution.fs: ComputeItemRange now returns (itemRange, itemIdentRange). itemRange is the structural whole-long-id span for typed-tree construction. itemIdentRange is the terminal identifier's range for diagnostics and sinks. - CheckExpressions.fs: Intercept UnresolvedOverloading errors in TcMethodApplication and narrow the error range to the method name. - ServiceParamInfoLocations.fs: Update getAllCurriedArgsAtPosition to handle narrowed symbol-use ranges by also checking the leaf function expression. Fixes #14284, #3920 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
5b96681 to
55769f8
Compare
|
|
||
| // mItem is the textual range covered by the long identifiers that make up the item | ||
| and TcItemThen (cenv: cenv) (overallTy: OverallTy) env tpenv (tinstEnclosing, item, mItem, rest, afterResolution) staticTyOpt delayed = | ||
| and TcItemThen (cenv: cenv) (overallTy: OverallTy) env tpenv (tinstEnclosing, item, mItem, _mItemIdent, rest, afterResolution) staticTyOpt delayed = |
There was a problem hiding this comment.
What's the point of adding this parameter (_mItemIdent) that's only discarded?
Fixes #14284, #3920
Problem
The FS0041 'No overloads match for method' error covered the entire expression including object access chains and arguments. For
T.Instance.Method(""), the error underlined everything fromTto). This is especially problematic on larger expressions where the wide error range hides other diagnostics.Similarly, FSharpSymbolUse ranges reported through the name-resolution sink (used by Find Usages, symbol highlight, and semantic classification) covered the whole dotted long-identifier span instead of just the terminal identifier.
Changes
NameResolution.fs/fsi
ComputeItemRangenow returns(itemRange, itemIdentRange):ResolveLongIdentAsExprAndComputeRangeandResolveExprDotLongIdentAndComputeRangepropagateitemIdentRangeand use it forCallMethodGroupNameResolutionSinkCheckExpressions.fs
TcMethodApplication: interceptsUnresolvedOverloadingerrors and narrows the range from the whole expression to just the method name, with guards for multiline expressions, generic constructors, and backtick-escaped namesServiceParamInfoLocations.fs
getAllCurriedArgsAtPosition: updated to handle narrowed symbol-use ranges by checking whetherposfalls within the leaf function expression's range (excluding infix applications)Tests
OverloadResolutionErrorRangeTests.fsBefore
Error underlines
T.Instance.Method("")— the entire expression.After
Error underlines only
Method— the method name.