microsoft / microsoft/typespec

Wrongfully detected cycle drops properties

Open
#7,972 0 comments 0 reactions 0 assignees View on GitHub
bug compiler:core needs-area triaged:core
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

Follow up to #7899 which fixed most cases.

This similiar to what is blocking #7956 needs a redesign of how we check for circular refernce in alias so we detect that when hitting a model property we break the cycle.

What happens here is that in `checkAlias` we wrongfully find a cycle but because its a template `DefaultBaseParameters` the error is not reported(so it wouldn't report duplicate errors) but the alias type is set to `errorType` resulting in the spread being a noop.

## Repro
```tsp
model DefaultBaseParameters {
...Alias;
}

model B {
prop: C;
}

model C {
...DefaultBaseParameters<{}>;
}

alias Alias = B;
```

https://typespec.io/playground/?e=%40typespec%2Fopenapi3&c=bW9kZWwgRGVmYXVsdEJhc2VQYXJhbWV0ZXJzPFQ%2BIHsKICAuLi5BbGlhczsKfQoKxjBCxRlwcm9wOiBDyxhDyDHWUXt9PsUtYcRPIMVVID0gQjs%3D&options=%7B%7D&vs=%7B%7D

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.