Skip to content

Add name collision detection for flat module compilation (#110)#188

Merged
aallan merged 1 commit into
mainfrom
feature/name-collision-detection
Mar 3, 2026
Merged

Add name collision detection for flat module compilation (#110)#188
aallan merged 1 commit into
mainfrom
feature/name-collision-detection

Conversation

@aallan

@aallan aallan commented Mar 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • When two imported modules define a function, data type, or constructor with the same name, the compiler now reports a clear error (E608/E609/E610) listing both conflicting modules
  • Previously, the first module registered silently won and the second was ignored, producing silently wrong code
  • Provenance tracking in _register_modules detects collisions across functions, ADT types, and constructors
  • Local definitions continue to shadow imported names without error
  • Same-module duplicates (module imported twice) are not treated as collisions
  • Follow-up issue Module-qualified call disambiguation via name mangling #187 tracks qualified-call disambiguation via name mangling

Files changed (13)

File Change
vera/codegen/modules.py Provenance tracking, collision detection, 3 new helper methods
vera/errors.py Add E608, E609, E610
tests/test_codegen_modules.py 7 new tests in TestNameCollisionDetection
SKILLS.md Update modules section re: collision errors and :: limitation
vera/README.md Error code range, limitations table
spec/11-compilation.md Update known-limitation text and limitations table
CHANGELOG.md v0.0.57 entry
README.md Test count (1,344), roadmap strikeout, #187 in C8.5
TESTING.md Test count, feature coverage row
vera/__init__.py Version 0.0.57
pyproject.toml Version 0.0.57
tests/test_readme.py Allowlist line number shift
scripts/check_readme_examples.py Allowlist line number shift

Test plan

  • 7 new collision detection tests pass
  • All 1,344 tests pass (pytest tests/ -q)
  • mypy clean (mypy vera/)
  • All 15 examples pass (python scripts/check_examples.py)
  • Version sync check passes (python scripts/check_version_sync.py)
  • Pre-commit hooks pass (mypy, pytest, examples, readme)

Closes #110

🤖 Generated with Claude Code

When two imported modules define a function, data type, or constructor
with the same name, the compiler now reports a clear error (E608/E609/
E610) listing both conflicting modules. Previously, the first module
registered silently won and the second was ignored.

- Provenance tracking in _register_modules detects cross-module collisions
- New error codes: E608 (function), E609 (ADT type), E610 (constructor)
- Local definitions shadow imports without error; same-module duplicates
  are not collisions
- 7 new tests in TestNameCollisionDetection (1,344 total)
- Follow-up issue #187 tracks qualified-call disambiguation via mangling
- Documentation updates: SKILLS.md, vera/README.md, spec/11-compilation.md,
  CHANGELOG, README, TESTING
- Version 0.0.57

Closes #110

Co-Authored-By: Claude <noreply@anthropic.invalid>
@aallan aallan merged commit 50d7310 into main Mar 3, 2026
10 checks passed
@aallan aallan deleted the feature/name-collision-detection branch March 3, 2026 21:05
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.

Name collision risk with flat module compilation

1 participant