Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 23, 2025

Name collision detection during package prefix trimming only checked against model types, missing collisions with union-derived enums.

Changes

  • Enhanced nameCollision function to check against:
    • sdkPackage.enums - catches unions that become enums

Example

// Before: only checked models
union IndexerStatus { Running, Stopped, Failed }
model SearchIndexerStatus { ... }  // "Search" prefix trimmed → "IndexerStatus" ❌ collision missed

// After: checks models, enums, and clients
// Now properly detects: "type SearchIndexerStatus was renamed to IndexerStatus which collides with an existing type name"

The collision check now aligns with the comment that previously claimed "clients and enums get a suffix" - it verifies they won't collide during the rename phase.

Original prompt

This section details on the original issue you should resolve

<issue_title>Enhance name collision logic</issue_title>
<issue_description>For this case, emitter trimmed packagePrefix for model type, the model name will be IndexerStatus, which is conflict with the union type name.
Image

But our nameCollision function only detected names in models, the emitter doesn't throw error for this kind of naming collision.
Image</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: JiaqiZhang-Dev <194873822+JiaqiZhang-Dev@users.noreply.github.com>
Copilot AI changed the title [WIP] Enhance name collision logic in emitter Expand name collision detection to include enums and clients Dec 23, 2025
Copilot AI requested a review from JiaqiZhang-Dev December 23, 2025 04:15
@JiaqiZhang-Dev
Copy link
Member

Test

tsp:
image

emitter detected the name collision and throw an error:
image

ReleaseHelper added 2 commits January 8, 2026 14:26
@JiaqiZhang-Dev JiaqiZhang-Dev marked this pull request as ready for review January 8, 2026 06:28
Copilot AI review requested due to automatic review settings January 8, 2026 06:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in name collision detection when package prefixes are trimmed from TypeSpec-generated Go types. Previously, only model types were checked for collisions, but union-derived enums were missed. This could result in a model like SearchIndexerStatus being renamed to IndexerStatus and colliding with an existing enum of the same name without any error being raised.

Key changes:

  • Enhanced the nameCollision function to check against sdkPackage.enums in addition to sdkPackage.models
  • Updated inline comment to reflect that both model and enum types are now checked
  • Incremented package version from 0.9.0 to 0.9.1

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/typespec-go/src/tcgcadapter/adapter.ts Added enum collision detection loop in nameCollision function and updated comment
packages/typespec-go/package.json Bumped version from 0.9.0 to 0.9.1 for bug fix release
packages/typespec-go/CHANGELOG.md Added entry documenting the union type collision fix

@JiaqiZhang-Dev JiaqiZhang-Dev changed the title Expand name collision detection to include enums and clients Expand name collision detection to include enums Jan 8, 2026
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.

Enhance name collision logic

2 participants