microsoft / microsoft/typespec

[Bug]: @defaultVisibility produces a compiler error when use with Versioning

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

Description

### Describe the bug

Using an enum declaration with @defaultVisibility decorator produces an error if used with Versioning.

### Reproduction

Added the following declaration
```
@defaultVisibility(Dummy.A,Dummy.B,Dummy.C)
enum Dummy
{
A, B, C
}
```
in both HTTP Service and API Versioning examples in playground.
First one HTTP Service is working well:
[Playground Link](https://typespec.io/playground/?c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7Cgp1c2luZyBIdHRwOwpAc2VydmljZSgjeyB0aXRsZTogIldpZGdldCBTxhoiIH0pCm5hbWVzcGFjZSBEZW1vxxo7CgpAZGVmYXVsdFZpc2liaWxpdHkoRHVtbXkuQSwgxglCyAlDKQplbnVtxg4gewogIEEsCiAgQsQFQywKfQoKbW9kZWwgx37EIUB2yldMaWZlY3ljbGUuUmVhZCkKICBpZDogc3RyaW5nOwoKICB3ZWlnaHQ6IGludDMyOwogIGNvbG9yOiAicmVkIiB8ICJibHVlIjvEaUBlcnJvcsdwRcQMxW9jb2Rly0BtZXNzYWdlymXEOnJvdXRlKCIvd%2BUApnMiKQpAdGFnKOcBNMQQaW50ZXJm5AErxxTFXC8qKiBMaXN0IMc5ICov5ADh5ADqbGlzdCgpOscvW10gfOYAlOUA1sQ45ADx0zhyZWFkKEBwYXRo5QELxj8uaWTJS9FJQ3JlYXRlIGHHTcdMcG9zdCBjxRsoQGJvZHnHH8hH2lBVcGTUUGF0Y2ggdcUcKAogIMYT7wCl5AH2ICDOb01lcmdlUMQ%2Bxlk8xi4%2BxCz6AIVEZWxl8gCFZMYWxgf3ASZ2b2lkyk%2FGTkFuYWx5etFP5wH3e2lkfS9hxiMiKecBO8cQ12XmAj3KZ30K&e=%40typespec%2Fopenapi3&options=%7B%22linterRuleSet%22%3A%7B%22extends%22%3A%5B%22%40typespec%2Fhttp%2Fall%22%5D%7D%7D)

Second one, API Versioning produces a `The default visibility modifiers of a class must be members of the class enum.` error:
[Playground Link](https://typespec.io/playground/?c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7CtIZcmVzdNUZdmVyc2lvbmluZyI7Cgp1c2luZyBWyRQ7CgpAxyJlZCjHGHMpCkBzZXJ2aWNlKCN7IHRpdGxlOiAiV2lkZ2V0IFPGGiIgfSkKbmFtZXNwYWNlIERlbW%2FHGsRUZGVmYXVsdFZpc2liaWxpdHkoRHVtbXkuQSwgxglCyAlDKQplbnVtxg4gewogIEEsCiAgQsQFQywKfQrGH%2BgAm8UidjHEHnYyxR%2FmANNIdHRwO8cMUmVzdDsKCm1vZGVsIOcAtsQ3QGtleSBpZDogc3Ry5QD8ICB3ZWlnaHQ6IGludDMyxBFjb2xvcjogInJlZCIgfCAiYmx1ZSLEGUBhZGTrASMudjIpIOQA%2F8pOfQoKQGVycm9yx3pFxAzFeWNvZGXLZG1lc3NhZ846aW50ZXJm5AFK5gCx5wFMIGV4dGVuZHPkANRvdXJjZS7ICU9wZXJhdOQAizzGMizGcT7FcvMArsQWZ2V0xAdyb3V0ZSgiY3VzdG9tR2V0IsQdyQ4oKTrnAIXkAJo%3D&e=%40typespec%2Fopenapi3&options=%7B%7D)

### Checklist

- [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
- [x] Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- [x] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/Microsoft/typespec/discussions).
- [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.

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.