Skip to content

fix: reject multiply-instantiated modules in resolver#76

Merged
avrabe merged 1 commit intomainfrom
fix/reject-multiply-instantiated-modules
Apr 2, 2026
Merged

fix: reject multiply-instantiated modules in resolver#76
avrabe merged 1 commit intomainfrom
fix/reject-multiply-instantiated-modules

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Apr 1, 2026

Summary

  • Add early detection of multiply-instantiated modules in the resolver's resolve_via_instances, before the module_to_instance HashMap is built (which silently drops duplicates via last-write-wins)
  • Defense-in-depth: the merger already has check_no_duplicate_instantiations, but the resolver runs first and would produce a corrupted dependency graph
  • Reuses the existing DuplicateModuleInstantiation error variant for consistent error messages

Closes #24

Test plan

  • test_multiply_instantiated_module_rejected — verifies duplicate module instantiation is caught with correct error message
  • test_distinct_module_instantiations_accepted — verifies distinct modules pass validation
  • All 166 unit tests pass (4 pre-existing failures on main unrelated to this change)
  • Existing merger tests (test_duplicate_module_instantiation_rejected, test_single_instantiation_accepted, test_no_instances_accepted) still pass

🤖 Generated with Claude Code

The merger already rejects multiply-instantiated modules, but the
resolver runs first and silently builds a corrupt module_to_instance
HashMap (last-write-wins). Add early detection in resolve_via_instances
before the map is constructed, so the error is caught at the earliest
pipeline stage. Closes #24.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@avrabe avrabe merged commit bef0503 into main Apr 2, 2026
3 of 4 checks passed
@avrabe avrabe deleted the fix/reject-multiply-instantiated-modules branch April 2, 2026 00:15
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.

Handle multiply-instantiated modules

1 participant