Skip to content

🐛 fix(lang): reject duplicate def and conflicting members across module declarations - #2711

Open
harehare wants to merge 2 commits into
mainfrom
fix/lang-module-duplicate-def
Open

harehare wants to merge 2 commits into
mainfrom
fix/lang-module-duplicate-def

Conversation

@harehare

@harehare harehare commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

A module now errors when it binds the same name through def, or through a def and a let/var. Redeclaring module m keeps extending the existing module, but a member already bound by an earlier declaration in the same scope is rejected instead of silently replaced. Document the rule in modules_and_imports.md.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor
  • 📝 Documentation
  • ⚡ Performance
  • ✅ Test
  • 📦 Build / dependencies
  • 👷 CI

Checklist

  • I ran cargo fmt and cargo clippy and addressed any warnings
  • I ran just test-all and all tests pass
  • I added or updated tests covering this change
  • I updated relevant documentation (/docs, crate README.md) if needed

Additional Context

…le declarations

A module now errors when it binds the same name through `def`, or through a
`def` and a `let`/`var`. Redeclaring `module m` keeps extending the existing
module, but a member already bound by an earlier declaration in the same scope
is rejected instead of silently replaced. Document the rule in
modules_and_imports.md.
@codspeed

codspeed Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing fix/lang-module-duplicate-def (08a2721) with main (bd7b48c)2

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (6563581) during the generation of this report, so bd7b48c was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

…modules

The sibling-extension check now tracks full qualified member paths and
descends into nested module bodies, so `outer::inner::a` declared across two
`outer` extensions is rejected instead of silently replaced. The check also
runs for function and block bodies and for the directive list of an imported
or included file. An imported file that binds the same name through `def` or
`let` more than once is rejected before its functions are compiled.

This branch has not been deployed

No deployments
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.

1 participant