fix(lower): #insert-expansion visibility exemption + close 0106 [stdlib B attempt-2]
Folds the coupled 0106 fix into Phase B. attempt-1 tightened the bare-name
visibility adapters (isNameVisible/isCImportVisible) to the flat_import_graph
edge set via the unified isVisible(.user_bare_flat/.c_import_bare) predicate;
that surfaced issue 0106 — std.print / log.* expand `#insert build_format(fmt)`
(comptime call) and `#insert "out(result);"` (inserted stmt) in the CONSUMER's
current_source_file, so their library-internal bare names were policed against
the consumer's imports and errored (run_examples 471 -> 467).
Fix: a precise, named exemption. Lowering.in_insert_expansion is set across
lowerInsertExprValue (the comptime eval + the parsed-back statements); the two
visibility adapters fall open while it is set — mirroring the existing
UFCS-alias / mangled-local "compiler indirection" exemptions. NOT a blanket
skip: scoped to #insert-expanded code, ordinary bare references stay policed.
Library-internal call bodies (build_format's concat/substr) already resolve in
the defining module — lowerFunctionBodyInto pins their current_source_file.
The flat tightening stays: a bare reference to a namespaced-only import's
internal name now correctly errors ('<name>' is not visible). This is the
Agra-ratified user-visible semantics change.
- face #1 pinned: examples/0736-modules-namespaced-only-bare-not-visible.sx
(+ a.sx) — exit 1 + stderr; fail-before (import_graph compiled it, exit 0) /
pass-after (flat set errors, exit 1).
- face #2 restored: examples 0015 / 0700 / 0718 / 1030 pass again.
- run_examples 471 -> 472 (the new regression).
- issues/0106 marked RESOLVED; readme.md documents namespaced-only visibility.
Collectors + unified predicate from attempt-1 (resolver.zig) unchanged; nothing
routes resolution AUTHOR-SELECTION through them yet (that is Phase C).
This commit is contained in:
@@ -1,5 +1,36 @@
|
||||
# 0106 — namespaced-import internal names are silently bare-visible (over-permissive `isNameVisible`)
|
||||
|
||||
> **RESOLVED** (flow stdlib/B attempt-2). Two coupled changes:
|
||||
>
|
||||
> 1. **Tightened bare visibility to the flat edge set.** `isNameVisible` /
|
||||
> `isCImportVisible` now route through the unified `isVisible` predicate over
|
||||
> `user_bare_flat` / `c_import_bare` (both join over `flat_import_graph`, not
|
||||
> `import_graph`). A namespaced-only import's internal name is no longer
|
||||
> bare-visible — face #1 now errors `'<name>' is not visible; #import the
|
||||
> module that declares it`.
|
||||
> 2. **`#insert`-expansion visibility exemption.** The flat tightening alone broke
|
||||
> `std.print` / `log.*`: a library metaprogram's `#insert build_format(fmt)`
|
||||
> (comptime call) and `#insert "out(result);"` (inserted statement) expand in
|
||||
> the CALL SITE's `current_source_file`, so their bare names (`build_format`,
|
||||
> `out`, `emit`) were policed against the consumer's imports. Fix: a precise,
|
||||
> named exemption — `Lowering.in_insert_expansion` is set across
|
||||
> `lowerInsertExprValue` (the comptime eval + the parsed-back statements), and
|
||||
> `isNameVisible` / `isCImportVisible` fall open while it is set. This mirrors
|
||||
> the existing UFCS-alias / mangled-local "compiler indirection" exemptions; it
|
||||
> is NOT a blanket skip (it scopes to `#insert`-expanded code; ordinary bare
|
||||
> references are still policed). Library-internal call bodies (e.g.
|
||||
> `build_format`'s `concat` / `substr`) already resolve correctly — they lower
|
||||
> via `lowerFunctionBodyInto`, which pins `current_source_file` to the defining
|
||||
> module.
|
||||
>
|
||||
> Root cause: `isNameVisible` walked `import_graph` (flat AND namespaced edges)
|
||||
> where a bare name should join only over `flat_import_graph`.
|
||||
> Regression: `examples/0736-modules-namespaced-only-bare-not-visible.sx` (+
|
||||
> `0736-…/a.sx`) — face #1 pinned (exit 1 + the stderr). Face #2 restored:
|
||||
> `examples/0015 / 0700 / 0718 / 1030` pass again (`run_examples` 471 → 472).
|
||||
> Fix in `src/ir/lower.zig` (`in_insert_expansion` + the two adapters) +
|
||||
> `src/ir/resolver.zig` (`VisibilityMode` modes, landed in attempt-1).
|
||||
|
||||
**Symptom.** A bare reference to a top-level name authored in a module that the
|
||||
consumer imports **only namespaced** (`ns :: #import "m.sx"`) is silently
|
||||
visible from the consumer. Observed: it compiles + runs. Expected: an error —
|
||||
|
||||
Reference in New Issue
Block a user