Skip to content

Narrow 'No matching overload' error range to method name only#19505

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-9141961-29048891-ac83c611-04a8-4bbc-9d1f-393ac1d7c4ba
Draft

Narrow 'No matching overload' error range to method name only#19505
Copilot wants to merge 2 commits intomainfrom
copilot/fix-9141961-29048891-ac83c611-04a8-4bbc-9d1f-393ac1d7c4ba

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 26, 2026

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 from T to "). 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: After ResolveOverloadingForCall returns, intercept UnresolvedOverloading errors and narrow the range from the whole expression (mMethExpr) to just the method name identifier. The method-name-only range is computed from mItem.End and methodName.Length.

  • tests/FSharp.Compiler.ComponentTests/ErrorMessages/OverloadResolutionErrorRangeTests.fs: Added 4 regression tests verifying the error range covers only the method name for:

    • Instance method calls (T.Instance.Method(""))
    • Static method calls (T.Method(""))
    • Chained expressions (T.Instance.Next.Next.Method(""))
    • Lambda arguments (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.

@T-Gro
Copy link
Copy Markdown
Member

T-Gro commented Mar 27, 2026

@copilot : Try again

@T-Gro
Copy link
Copy Markdown
Member

T-Gro commented Mar 27, 2026

@copilot : Try again.

@abonie
Copy link
Copy Markdown
Member

abonie commented Mar 31, 2026

@copilot Try again

…only

In TcMethodApplication, remap UnresolvedOverloading error range from the
whole expression (mMethExpr) to just the method name identifier. This
prevents the error from covering the entire expression including object
access chains and arguments.

Add regression tests for instance calls, static calls, chained expressions,
and lambda arguments.

Agent-Logs-Url: https://github.com/dotnet/fsharp/sessions/d3913698-2bf7-4b33-8c76-1079e067156b

Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 31, 2026

@copilot Try again

Implemented the fix in commit aa4c1a9. The UnresolvedOverloading error range is now narrowed from the whole expression (mMethExpr) to just the method name identifier by computing the method-name-only range from mItem.End and methodName.Length in TcMethodApplication.

For T.Instance.Method(""), the error now covers only Method (Col 12-18) instead of the entire T.Instance.Method("") expression (Col 1-22). Added 4 regression tests covering instance calls, static calls, chained expressions, and lambda arguments. Tests and compiler build pass. Release notes and full test suite validation still pending.

Copilot AI changed the title [WIP] Copilot Request Narrow 'No matching overload' error range to method name only Mar 31, 2026
Copilot AI requested a review from abonie March 31, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

3 participants