Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@typespec/compiler"
---

Addressed a bug that could cause duplicate `@encodedName` applications to be detected when none actually exist.
11 changes: 10 additions & 1 deletion packages/compiler/src/lib/encoded-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,16 @@ export function validateEncodedNamesConflicts(program: Program) {

for (const [target, map] of getEncodedNamesStateMap(program).entries()) {
const scope = getScope(target);
if (scope === undefined) {
const memberValues = new Set(scope?.members.values());
if (
scope === undefined ||
// Workaround: exclude members that aren't actually in the scope. This can happen when types of
// properties, enum members, or union variants are cloned for one reason or another, but are not
// actually attached to the parent type. This should probably be fixed in cloning logic (mutator
// implementation) instead, but for now this workaround solves some problems with false positives
// in duplication tracking here.
!memberValues.has(target)
) {
return;
}
for (const [mimeType, name] of map.entries()) {
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/src/lib/visibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ function createVisibilityFilterMutator(
realm.remove(clone);
modified = true;
} else {
const mutated = mutateSubgraph(program, [mpMutator], prop);
const mutated = cachedMutateSubgraph(program, mpMutator, prop);

clone.properties.set(key, mutated.type as ModelProperty);

Expand Down
Loading