Skip to content

Fix function call argument count errors reporting on declaration instead of call site#10859

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/functions-reporting-errors-fix
Draft

Fix function call argument count errors reporting on declaration instead of call site#10859
Copilot wants to merge 2 commits into
mainfrom
copilot/functions-reporting-errors-fix

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 2, 2026

invalid-argument-count diagnostics for function calls were targeting the extern fn declaration node instead of the call expression, causing errors to appear on the wrong line.

extern fn testFn(args: valueof unknown): Reflection.Operation;

// Error was reported on line 1 (declaration) instead of here:
alias T = testFn(original, #["b", "a"]);

Changes

  • packages/compiler/src/core/checker.tscheckFunctionCallArguments now takes the CallExpressionNode and uses it as the diagnostic target instead of target.node!
  • packages/compiler/test/checker/functions.test.ts — Added test asserting the diagnostic targets SyntaxKind.CallExpression

… function declaration

Fixes the diagnostic target for `invalid-argument-count` errors in function calls
to point at the CallExpressionNode (the call site) instead of the function
declaration node. This ensures errors are shown where the function is called,
not where it is defined.

Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix functions reporting errors on function declaration Fix function call argument count errors reporting on declaration instead of call site Jun 2, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added the compiler:core Issues for @typespec/compiler label Jun 2, 2026
Copilot AI requested a review from markcowl June 2, 2026 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler:core Issues for @typespec/compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

functions reporting errors of usage on teh function declaration

2 participants