Narrow 'No matching overload' error range to method name only#19505
Narrow 'No matching overload' error range to method name only#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
|
| // Narrow the error range for unresolved overloading from the whole expression (mMethExpr) | ||
| // to just the method name. For instance calls like T.Instance.Method(""), mItem covers | ||
| // the entire "T.Instance.Method" range, so we compute the method-name-only range from | ||
| // the end of mItem and the method name length. See https://github.com/dotnet/fsharp/issues/14190. |
There was a problem hiding this comment.
@T-Gro Have you considered changing how mItem is calculated instead? I think we can get it from the syntax at an earlier stage instead of trying to compute it here.
There was a problem hiding this comment.
This is a related issue: #3920
If proper ranges are used during type checking, we won't have to trim them later in the tooling (like it's done for Find Usages and symbol highlighting) or trim them on a case-by-case basis like here.
04c3c67 to
49d2bbf
Compare
Narrows the error range for FS0041 (No overloads match for method) from
covering the entire expression to just the method name. For example,
T.Instance.Method(""") now highlights only 'Method' instead of the
whole 'T.Instance.Method(""")'.
The narrowing is applied in TcMethodApplication after overload resolution
fails. It computes the method-name-only range from the end of mItem,
with guards for multi-line expressions and generic constructors whose
internal names may be longer than the source text.
Includes:
- New OverloadResolutionErrorRangeTests with 4 test cases
- Updated 35+ baseline files for narrowed FS0041 error ranges
- Release notes entry
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
3420474 to
2751d6e
Compare
The "No overloads match for method" error (Error 41) previously covered the entire expression including object access chains and arguments. For example,
T.Instance.Method("")would underline everything fromTto"). This is especially problematic on larger expressions where the wide error range hides other errors and warnings.Changes Made
src/Compiler/Checking/Expressions/CheckExpressions.fs: AfterResolveOverloadingForCallreturns, interceptUnresolvedOverloadingerrors and narrow the range from the whole expression (mMethExpr) to just the method name identifier. The method-name-only range is computed frommItem.EndandmethodName.Length.tests/FSharp.Compiler.ComponentTests/ErrorMessages/OverloadResolutionErrorRangeTests.fs: Added 4 regression tests verifying the error range covers only the method name for:T.Instance.Method(""))T.Method(""))T.Instance.Next.Next.Method(""))T.Instance.Method(fun () -> ""))Before
Error underlines the entire
T.Instance.Method("")expression.After
Error underlines only
Method, leaving the rest of the expression clean for other diagnostics.📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.