The generic-struct author-selection matrix {bare,qualified} × {site} × {layout,
body} drifted per-site across 12 attempts because method bodies were resolved by
bare template name in `fn_ast_map["Box.method"]`, independent of which author
produced the instance's layout. Collapse it into four choke-points so
layout-author ≡ body-author by construction:
CP-1 `selectGenericStructHead` — the single layout-head selector every generic
struct head site funnels through (alias-RHS .call/.parameterized, array-
literal, static head, resolveTypeCall/ParameterizedWithBindings). Emits the
visibility / missing-member diagnostics inline; returns a control-flow-only
union. No head site reads `struct_template_map` for selection directly.
CP-2 author stamp — non-optional `decl: *StructDecl` on `StructTemplate` (set at
the sole producer `buildGenericStructTemplate`) + `struct_instance_author`
written at `instantiateGenericStruct` from the SAME `tmpl` that builds the
layout; re-stamped on the dedup fast-path so an instance is never returned
without an author.
CP-3 alias metadata copy — mirror template/bindings/author from the mangled
instance onto the alias display name, so an `ABox`-typed receiver is a
first-class dispatch instance (Counter-2).
CP-4 `genericInstanceMethod` / `ensureGenericInstanceMethodLowered` — the single
body reader: inline methods select via the stamped author (`structMethodFn`,
source-pin follows for free); impl-block methods fall back to the template-
keyed `fn_ast_map` entry. Routes the four bespoke body sites (static head,
instance dispatch, param typing, protocol thunk) + the new qualified static
head (`a.Box(s64).make(7)`, finding #2).
A debug assert locks `struct_instance_author` / `struct_instance_template` keyset
coincidence so a future third writer that forgets the author trips a test.
Goldens 0777/0778/0780 (bare instance method — ptr/by-value/param-typed, finding
#1), 0779/0785 (qualified static head + missing member, finding #2), 0783 (alias
instance dispatch, Counter-2), 0782 (ambiguity containment). 0414/0415/0543 and
the FFI suites stay green.
20 lines
804 B
Plaintext
20 lines
804 B
Plaintext
// A QUALIFIED generic static-method head `a.Box(s64).make(7)` where namespace `a`
|
|
// exists but authors NO member named `Box` must DIAGNOSE the missing member —
|
|
// never silently fall back to the bare last-wins `struct_template_map` and
|
|
// instantiate an unrelated module's same-name `Box` (parallels 0775 for the
|
|
// static-method head).
|
|
//
|
|
// `a.sx` authors only `Other` (no `Box`); `b.sx` authors a generic `Box($T)`.
|
|
// The qualified static head `a.Box(s64).make(7)` must report that `a` has no
|
|
// member `Box`, NOT resolve to `b.Box.make`.
|
|
|
|
#import "modules/std.sx";
|
|
a :: #import "0785-modules-qualified-generic-static-missing-member/a.sx";
|
|
b :: #import "0785-modules-qualified-generic-static-missing-member/b.sx";
|
|
|
|
main :: () -> s32 {
|
|
x := a.Box(s64).make(7);
|
|
print("{}\n", x.x);
|
|
0
|
|
}
|