Repository navigation
Conversation
Add DeclId, SingleEntry, and DuplicatedDeclarationError types, and insert.rs to track interface declarations per source and report duplicates as load errors instead of silently overwriting. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
dak2
force-pushed
the
rust-environment-duplicate-decl-detection
branch
from
October 12, 2026 01:33
b6cbb4f to
c1cf045
Compare
Register type aliases in their own table so duplicates are reported as load errors, as is already done for interfaces. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Report them as load errors instead of silently overwriting, as is already done for interfaces and type aliases. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Declarations inside a module were never reached, so a duplicate such as two `interface Foo::_I` went undetected. Register modules as one entry per name, recurse into their bodies with the enclosing namespace, and record each declaration's context. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Ruby keeps classes and modules in one `class_decls` table, so a name is either a class or a module. Split the entry into `ClassEntry` and `ModuleEntry` over a shared layout, and report a duplicated declaration when a name is reopened as the other kind. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Constant lookup needs constant entries, and Ruby's Environment rejects a constant that shares a name with a class or module. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Ruby keeps module aliases in the same constant name space as classes, modules and constants, so `module Foo = Kernel` followed by `module Foo` or `Foo: String` must raise a duplication error. module_entry now returns ModuleLookup since an alias has no ModuleEntry. class_entry is unchanged until class aliases are registered. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Skipping them let a class, module, constant or module alias reuse an alias name undetected, and class_entry could not see an alias, unlike Ruby. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Comments restating what the code does drift from it; the code and test names already say that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Type name and string IDs are already xxh3 hashes, so the interners now use IdHasher instead of re-hashing with SipHash. concat skips the segments Vec for single-segment names, the common case. Most classes and modules are declared once, so Entry keeps the first declaration inline and allocates only for reopenings. primary_decl is fixed at registration instead of scanning declarations on every call, which also lets it drop the &Environment argument. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of #2954.
Ports
RBS::Environment#insert_rbs_decl: registers declarations by absolute name and reports duplicates asRBS::DuplicatedDeclarationErrordoes.Alias normalization, type name resolution, and type parameter validation are follow-ups.
🤖 Generated with Claude Code