ir: whole-program passes pin the source context per decl (fix 0122)
convergeClosureShapeSets, checkErrorFlow, and the unknown-type loop ran under whatever current_source_file the previous phase left behind — closure-literal annotations resolved (and reject/unknown-type diagnostics rendered) against an arbitrary module. Latent while std.sx was a single file (the ambient happened to be the main file); the re-export facade restructure exposed it. Each walk now pins setCurrentSourceFile per decl / per fn (body.source_file is already stamped by resolveImports). Coverage: examples 0129/1047/1049/1052/ 1053/1056 against the facade std.sx. Gates: zbt 426/426, suite 588/588.
This commit is contained in:
@@ -65,12 +65,17 @@ pub const UnknownTypeChecker = struct {
|
||||
var declared = std.StringHashMap(void).init(self.alloc);
|
||||
defer declared.deinit();
|
||||
self.collectDeclaredTypeNames(decls, &declared);
|
||||
const saved_file = self.diagnostics.current_source_file;
|
||||
defer self.diagnostics.current_source_file = saved_file;
|
||||
for (decls) |decl| {
|
||||
if (self.main_file) |mf| {
|
||||
if (decl.source_file) |sf| {
|
||||
if (!std.mem.eql(u8, sf, mf)) continue;
|
||||
}
|
||||
}
|
||||
// Render against the decl's own module, not the ambient file the
|
||||
// previous phase left behind (issue 0122).
|
||||
if (decl.source_file) |sf| self.diagnostics.current_source_file = sf;
|
||||
switch (decl.data) {
|
||||
.fn_decl => self.checkFnSignatureTypes(&decl.data.fn_decl, &declared),
|
||||
.struct_decl => |sd| self.checkStructFieldTypes(&sd, &declared),
|
||||
|
||||
Reference in New Issue
Block a user