fix(lower): fn-value site lazily lowers winner only on resolver .none [0102d F1]

The bare-fn-as-value site (func_ref / fn-ptr / closure coercion) eagerly
lazily-lowered the name-keyed first-wins WINNER before the resolveBareCallee
block could reroute a genuine flat same-name collision to its per-source
author. Taking a SHADOW author's fn value therefore lowered (and could
mis-diagnose) the unused winner's body. Move lazyLowerFunction INSIDE blk_fv
onto the `.none` fallback only, mirroring the closure(fn) and free-function
UFCS sites: on `.func` use the resolved author's FuncId and never touch the
winner; on `.none` fall through to lazy-lower + resolveFuncByName the winner.

Regression: examples/0735-modules-flat-same-name-fn-value-winner — the
first-wins winner's body is independently broken and never used; a shadow
taken as a function value binds the shadow and runs (exit 0) while the winner
is not lowered. Fails-before (unresolved symbol in the winner), passes-after.
This commit is contained in:
agra
2026-06-06 16:41:01 +03:00
parent bd24996d8b
commit 96e3d2d5ae
8 changed files with 46 additions and 6 deletions

View File

@@ -60,7 +60,9 @@ collision:
args fill from the RESOLVED author's defaults, not the winner's.
2. **Function-value conversion** (`closure(fn)` and the bare-fn-as-value
`func_ref` / fn-ptr / closure-coercion path): captures the resolved
author's FuncId.
author's FuncId. The winner's body is lazily lowered ONLY on the `.none`
fallback — a rerouted value never uses the winner, so taking a shadow as a
value must not pre-lower (and possibly mis-diagnose) the winner's body.
3. **Free-function UFCS** (`recv.fn()``fn(recv, …)`): dispatches the
resolved author for the receiver's source.
4. **Comptime `#run`** of a bare call: `lowerMainAndComptime` now sets
@@ -71,7 +73,7 @@ collision:
## Regression tests
`examples/0722``0734` (each a focused multi-file flat-collision scene that
`examples/0722``0735` (each a focused multi-file flat-collision scene that
fails on pre-fix code and passes after):
- `0722-modules-flat-same-name-own` — own-author wins on the call path.
@@ -93,3 +95,8 @@ fails on pre-fix code and passes after):
callee.
- `0734-modules-flat-same-name-ufcs-ambiguous``≥2` flat authors, UFCS call
→ loud diagnostic (pre-fix: silently bound the winner).
- `0735-modules-flat-same-name-fn-value-winner` — the first-wins winner's body
is independently broken and never used; a shadow taken as a function value
binds the shadow and runs while the winner is NOT lowered (pre-fix: the
fn-value site eagerly lowered the winner before the resolver rerouted,
surfacing the winner's error for a function the value never touches).