2.7 KiB
2.7 KiB
Name Resolution and Linking
Original Problem
PBS needed a deterministic model for:
- how module scope is formed,
- what imports actually make visible,
- how callable sets cross module boundaries,
- how builtin shells and host owners participate in lookup,
- and which failures belong to syntax, import resolution, linking, or static semantics.
Consolidated Decision
PBS resolves names by explicit namespace and explicit phase ownership.
The stable baseline is:
- A module is assembled from all
.pbsfiles before visibility filtering. mod.barrelis a visibility filter over existing declarations, not the source of declaration existence.- Imports target modules, not files.
- Only exported names become importable across modules.
- Aliases change only the local visible spelling, never canonical identity.
- Local-versus-import collisions are deterministic errors instead of silent shadowing.
- Duplicate imports are tolerated only when they denote the same canonical origin.
- Different-origin same-name imports are rejected in linking, before callsite analysis.
- Builtin shells and host owners participate through ordinary imported surfaces plus reserved metadata, not through a parallel hidden namespace.
- Member lookup on an already-typed builtin receiver belongs to static semantics, not linking.
Final Model
The phase boundary is now clear:
- syntax owns malformed source forms,
- manifest/import resolution owns locating module sources,
- linking owns visible declaration assembly across modules,
- static semantics owns meaning once the visible declaration space is already unambiguous.
This is the important operational closure: linking decides what can be seen; static semantics decides what that visible thing means.
Practical Consequences
When implementing PBS frontend resolution:
- Build module scope before applying barrel visibility.
- Resolve imported callable sets from exported overload sets only.
- Reject origin conflicts before overload resolution.
- Keep builtin simple types separate from imported builtin shells.
- Never let textual spelling outrank canonical owner identity.
Common Pitfalls
- Treating
mod.barrelas if it created declarations. - Deferring imported-origin conflicts until callsite resolution.
- Letting local and imported same-name declarations silently coexist.
- Promoting imported builtin shells to the same status as always-available simple builtin types.
Source Decisions
Name Resolution - Scope, Lookup, and Imports Decision.mdName Resolution - Callable Sets and Cross-Module Linking Decision.mdName Resolution - Builtin Shells and Host Owners Decision.mdName Resolution - Linking Phase Boundary Decision.md