Skip to content

Fail loudly on duplicate scoped identifiers in SymbolConverter#4570

Merged
pepone merged 2 commits intoicerpc:mainfrom
pepone:fix/named-type-duplicate-detection
Apr 29, 2026
Merged

Fail loudly on duplicate scoped identifiers in SymbolConverter#4570
pepone merged 2 commits intoicerpc:mainfrom
pepone:fix/named-type-duplicate-detection

Conversation

@pepone
Copy link
Copy Markdown
Member

@pepone pepone commented Apr 29, 2026

Fix #4500

Copilot AI review requested due to automatic review settings April 29, 2026 13:58
@pepone pepone force-pushed the fix/named-type-duplicate-detection branch from 93b2712 to 4c1c45b Compare April 29, 2026 14:01
Copy link
Copy Markdown

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 addresses issue #4500 by ensuring duplicate fully-scoped identifiers in SymbolConverter no longer get silently ignored during symbol indexing, making name collisions (or unexpected slicec output) immediately visible.

Changes:

  • Replace _named.TryAdd(...) with _named.Add(...) so duplicate keys throw instead of being silently dropped.
  • Add an explanatory comment documenting why duplicates are treated as a hard failure.

Comment on lines 57 to 60
// Scoped IDs are warned to be unique by the compiler, we can safely use them as dictionary keys.
_named.Add($"{moduleScope}::{id}", (file, symbol));
}
}
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

Dictionary.Add will throw an ArgumentException on duplicates, but the message typically won’t include which SliceFile(s) produced the conflicting symbols. Since this is intended to diagnose slicec/multi-file collisions, consider checking for an existing entry first and throwing with additional context (duplicate id + both file paths/symbol kinds) to make the failure easier to debug.

Copilot uses AI. Check for mistakes.
Comment thread src/ZeroC.Slice.Symbols/SymbolConverter.cs Outdated
Copy link
Copy Markdown
Member

@InsertCreativityHere InsertCreativityHere left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Co-authored-by: Joe George <joe@externl.com>
@pepone pepone merged commit 422d2a1 into icerpc:main Apr 29, 2026
8 checks passed
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.

[Audit-Low] named.TryAdd silently drops duplicate scoped identifiers

4 participants