Skip to content

Internal compiler error when using partially specialized method from imported typespec file #1772

Description

@johanste

main.tsp

import "./serviceCustomizations.tsp";

@service({
  title: "Contoso service",
})
namespace Azure.Contoso;

@TypeSpec.Rest.resource("products")
model Product {
  @key
  productId: string;
}

op placeOrder is Operations.ResourceCreateWithServiceProvidedName<Order>;

serviceCustomizations.tsp

import "@azure-tools/typespec-azure-core";

namespace Azure.Contoso;

using Azure.Core.Traits;

/*
  Define common service traits/operations
*/
alias ServiceTraits = SupportsClientRequestId & NoConditionalRequests & NoRepeatableRequests;

interface Operations extends Azure.Core.ResourceOperations<ServiceTraits> {}
$> tsp compile main.tsp
TypeSpec compiler v0.42.0

Internal compiler error!
File issue at https://github.com/microsoft/typespec

Error: Operation in interface should already have been checked.
    at compilerAssert (file:///Users/johanstenberg/repos/typespec-azure/core/packages/compiler/core/diagnostics.ts:293:9)
    at checkOperation (file:///Users/johanstenberg/repos/typespec-azure/core/packages/compiler/core/checker.ts:1583:7)
    at checkDeclaredType (file:///Users/johanstenberg/repos/typespec-azure/core/packages/compiler/core/checker.ts:1098:9)
    at getOrCheckDeclaredType (file:///Users/johanstenberg/repos/typespec-azure/core/packages/compiler/core/checker.ts:1074:12)
    at checkTypeReferenceSymbol (file:///Users/johanstenberg/repos/typespec-azure/core/packages/compiler/core/checker.ts:997:30)
    at checkOperationIs (file:///Users/johanstenberg/repos/typespec-azure/core/packages/compiler/core/checker.ts:1686:27)
    at checkOperation (file:///Users/johanstenberg/repos/typespec-azure/core/packages/compiler/core/checker.ts:1599:29)
    at getTypeForNode (file:///Users/johanstenberg/repos/typespec-azure/core/packages/compiler/core/checker.ts:619:16)
    at checkSourceFile (file:///Users/johanstenberg/repos/typespec-azure/core/packages/compiler/core/checker.ts:2257:7)
    at Object.checkProgram (file:///Users/johanstenberg/repos/typespec-azure/core/packages/compiler/core/checker.ts:2225:7)

If you change the Operations interface in serviceCustomizations.tsp to an alias, it compiles:

serviceCustomizations.tsp

import "@azure-tools/typespec-azure-core";

namespace Azure.Contoso;

using Azure.Core.Traits;

/*
  Define common service traits/operations
*/
alias ServiceTraits = SupportsClientRequestId & NoConditionalRequests & NoRepeatableRequests;

alias Operations = Azure.Core.ResourceOperations<ServiceTraits>;

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions