aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-05-11 23:20:22 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-05-11 23:20:22 -0700
commit71afc3088009944fcd8339ac71e69a0b77a781ab (patch)
treed370c17e3561870b151d402c1ba1b32813bda83d /src/Sema.zig
parent1ab1a96f87279375e656bba35280a85b62973255 (diff)
downloadzig-71afc3088009944fcd8339ac71e69a0b77a781ab.tar.gz
zig-71afc3088009944fcd8339ac71e69a0b77a781ab.zip
stage2: more Decl lifetime fixes
* File stores `root_decl: Decl` instead of `namespace: *Namespace`. This maps more cleanly to the actual ownership, since the `File` does own the root decl, but it does not directly own the `Namespace`. * `semaFile` completes the creation of the `Decl` even when semantic analysis fails. The `analysis` field of the `Decl` will contain the results of semantic analysis. This prevents cleaning up of memory still referenced by other Decl objects. * `semaDecl` sets `Struct.zir_index` of the root struct decl, which fixes use of undefined value in case the first update contained a ZIR compile error.
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index abb4f9e56a..cc77b00789 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -4409,7 +4409,7 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!
},
};
try mod.semaFile(result.file);
- return mod.constType(sema.arena, src, result.file.namespace.?.ty);
+ return mod.constType(sema.arena, src, result.file.root_decl.?.ty);
}
fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
@@ -7307,7 +7307,7 @@ fn getBuiltinType(
const opt_builtin_inst = try sema.analyzeNamespaceLookup(
block,
src,
- std_file.namespace.?,
+ std_file.root_decl.?.namespace,
"builtin",
);
const builtin_inst = try sema.analyzeLoad(block, src, opt_builtin_inst.?, src);