Skip to content

Conversation

witemple-msft
Copy link
Member

This is a very strange bug that likely stems from the way mutators work.

When mutating a model for visibility transforms, we create clones of the model's properties. These clones end up checked/finished, even if they are not actually attached to the model, and vice versa (the original properties may be checked/finished even if the clone ends up attached).

This runs stateful decorators, like @encodedName. Unfortunately, in these cases, it means that both the clone and the original property end up binding an encoded name within the same scope, which the validator later sees as a conflict.

However, only one of these properties is actually a member of the scope at validation time. This PR uses that to exclude "false members". These are properties that exist in the state map (the decorator has been applied to them), but aren't actually bound to the parent they claim to be a member of. We can work around this mutator bug in the validator by checking if the target is actually within the set of member values (in this case, the properties actually present in the parent model, but this will also work for enum members and union variants).

Closes #8599

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Copy link

pkg-pr-new bot commented Oct 7, 2025

Open in StackBlitz

npm i https://pkg.pr.new/microsoft/typespec/@typespec/compiler@8681

commit: fb0002c

Copy link
Contributor

github-actions bot commented Oct 7, 2025

All changed packages have been documented.

  • @typespec/compiler
Show changes

@typespec/compiler - fix ✏️

Addressed a bug that could cause duplicate @encodedName applications to be detected when none actually exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: encoded-name-conflict when using @visibility, @encodedName and a visibility transform together

2 participants