Files
sx/examples/0829-packs-param-impl-mixed-pack-source-ambiguous.sx
agra 6b0ebdd92b lang: require explicit receiver in protocol method declarations
Protocol method declarations now declare their receiver explicitly as the first
parameter — 'self: *Self' (or 'self: Self') — matching the impl method signature,
instead of the old implicit-receiver form where the listed params were only the
extra args. That asymmetry repeatedly caused confusion over whether the first
param was the receiver or an argument.

The parser validates the first param is 'self' typed Self/*Self, then strips it,
so all downstream lowering and the dispatch ABI are unchanged (impl blocks and
call sites are unaffected). A protocol method missing the receiver is now a parse
error.

Migrated all 129 protocol method signatures across library + examples (+ one
inline-sx test in sema.zig) to the explicit form. Updated specs.md + readme.md.

New: examples/0418-protocols-explicit-receiver.sx (feature),
examples/1190-diagnostics-protocol-missing-receiver.sx (negative/diagnostic).
2026-06-21 11:02:16 +03:00

37 lines
1.6 KiB
Plaintext

// E6BR-4 (MIXED pack source — the trap cell) — a pack-closure param-impl source
// `Closure(*Box, ..$args) -> $R` mixes a CONCRETE fixed prefix (`*Box`) with pack
// metadata (`..$args`, `$R`). The reconciled choke-point decides template-vs-author
// AT THE LEAF: `*Box` is resolved SOURCE-AWARE through `resolveCompound` while
// `..$args`/`$R` stay pack metadata via `PackResolver` — NOT a top-level
// "contains-unbound → no-author wrapper" router, which would send `*Box` down the
// global last-wins path (the trap both engines flagged). With two flat `Box`
// authors and none own, the concrete `*Box` prefix is a genuine collision and the
// build exits 1 — proving the prefix IS routed source-aware (it caught the
// ambiguity) while the pack parts did not spuriously error.
//
// Fail-before (pre-E6BR-4): the wrapped/pack source fell to the no-author
// `type_bridge.resolveTemplateSignatureType` wrapper (global last-wins, no
// diagnostic), so the `*Box` collision registered silently. Protects the pure-pack
// `Closure(..$args) -> $R` bridge in `library/modules/ffi/objc_block.sx` (0504 /
// 1302 / 1304 stay byte-identical), whose single author keeps the prefix-free path.
#import "modules/std.sx";
#import "0829-packs-param-impl-mixed-pack-source-ambiguous/a.sx";
#import "0829-packs-param-impl-mixed-pack-source-ambiguous/b.sx";
Block :: struct { tag: i32; }
Sink :: protocol(T: Type) {
convert :: (self: *Self) -> T;
}
impl Sink(Block) for Closure(*Box, ..$args) -> $R {
convert :: (self: Closure(*Box, ..$args) -> $R) -> Block {
.{ tag = 0 }
}
}
main :: () -> i32 {
0
}