Skip to content

Fix: allow function calls in op is expressions#10860

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-functions-in-op-is
Draft

Fix: allow function calls in op is expressions#10860
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-functions-in-op-is

Conversation

Copilot AI commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Function calls returning Operation could not be used directly in op is — the compiler reported "A value cannot be used as a type." An intermediate alias was required as a workaround.

// Before: required workaround
alias T = reorderParameters(Employees.move, #["a", "b"]);
op test is T;

// After: works directly
op test is reorderParameters(Employees.move, #["a", "b"]);

Changes

  • Parser: op is now uses parseCallOrReferenceExpression() instead of parseReferenceExpression(), accepting both type references and function calls
  • AST (types.ts): OperationSignatureReferenceNode.baseOperation widened to TypeReferenceNode | CallExpressionNode
  • Name resolver: Guards added to skip static symbol resolution for CallExpressionNode (results are dynamic)
  • Checker: checkOperationIs conditionally performs circular-reference checks only for TypeReferenceNode; CallExpressionNode flows through getTypeForNodecheckCallExpression as normal

Copilot AI linked an issue Jun 2, 2026 that may be closed by this pull request
Previously, writing `op test is myFunction(args)` would produce a
"A value cannot be used as a type" error, requiring an intermediate
alias as a workaround.

Changes:
- Parser: use parseCallOrReferenceExpression() for op is
- AST: baseOperation accepts TypeReferenceNode | CallExpressionNode
- Name resolver: guard against CallExpressionNode
- Checker: handle CallExpressionNode in checkOperationIs

Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the compiler:core Issues for @typespec/compiler label Jun 2, 2026
Copilot AI changed the title [WIP] Fix issue with functions in op is causing type error Fix: allow function calls in op is expressions Jun 2, 2026
Copilot AI requested a review from markcowl June 2, 2026 02:40
@microsoft-github-policy-service microsoft-github-policy-service Bot added the stale Mark a PR that hasn't been recently updated and will be closed. label Jun 16, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Hi @@copilot. Your PR has had no update for 14 days and it is marked as a stale PR. If it is not updated within 14 additional days, the PR will automatically be closed. If you want to refresh the PR, please remove the stale label.

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 stale Mark a PR that hasn't been recently updated and will be closed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot use functions in op is

2 participants