wip(E4): partial source-pin + non-transitive flip [stdlib E4 attempt-1 WIP checkpoint]
Incomplete WIP from a worker killed at the 55-min wall (large blast radius: core source-pin + ~8 example migrations + ~10 library module migrations). Committed so the resumed session continues on a clean tree. May not build.
This commit is contained in:
@@ -661,14 +661,39 @@ fn reportDuplicateName(diagnostics: ?*errors.DiagnosticList, added: bool, name:
|
||||
fn stampFnBodySource(decl: *Node, file_path: []const u8) void {
|
||||
switch (decl.data) {
|
||||
.fn_decl => |fd| fd.body.source_file = file_path,
|
||||
.struct_decl => |sd| stampStructMethodSources(sd, file_path),
|
||||
// A parameterized protocol is instantiated cross-module; record its
|
||||
// defining path so the instantiation resolves method-signature types in
|
||||
// this module (E4).
|
||||
.protocol_decl => decl.data.protocol_decl.source_file = file_path,
|
||||
.const_decl => |cd| switch (cd.value.data) {
|
||||
.fn_decl => |fd| fd.body.source_file = file_path,
|
||||
// `List :: struct { … append :: (…) { … } }` — the methods of a
|
||||
// (possibly generic) struct are monomorphized in their template's
|
||||
// OWN module (issue 0106 + the E4 instantiation source-pin), so their
|
||||
// bodies need the defining path stamped just like a top-level fn.
|
||||
.struct_decl => |sd| stampStructMethodSources(sd, file_path),
|
||||
.protocol_decl => cd.value.data.protocol_decl.source_file = file_path,
|
||||
else => {},
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
||||
/// Stamp the defining module path onto every method (and struct-level fn
|
||||
/// constant) body of a struct decl, so a generic-struct method monomorphized at
|
||||
/// a cross-module call site still pins to the module that declares it.
|
||||
fn stampStructMethodSources(sd: ast.StructDecl, file_path: []const u8) void {
|
||||
for (sd.methods) |m| {
|
||||
if (m.data == .fn_decl) m.data.fn_decl.body.source_file = file_path;
|
||||
}
|
||||
for (sd.constants) |c| {
|
||||
if (c.data == .const_decl and c.data.const_decl.value.data == .fn_decl) {
|
||||
c.data.const_decl.value.data.fn_decl.body.source_file = file_path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `reportDuplicateName` keyed off a node whose `declName()` carries the name
|
||||
/// (the regular authored-decl sites; an `import_decl` has no `declName`, so a
|
||||
/// namespace alias must use `reportDuplicateName` with the alias directly).
|
||||
|
||||
Reference in New Issue
Block a user