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

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 2, 2026

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
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.

Cannot use functions in op is

2 participants