mirror of
https://github.com/ziglang/zig.git
synced 2025-12-15 18:53:07 +00:00
stage2: fix anonymous Decl ty/val wrong arena
string literals and error set types were allocating the ty/val fields of the anonymous Decl into the owner Decl's arena, rather than the new anonymous Decl's arena as intended. This caused use of undefined value later on in the pipeline.
This commit is contained in:
parent
1af31baf0b
commit
072d1e088c
@ -1552,7 +1552,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor
|
||||
// are lifetime annotations in the ZIR.
|
||||
var decl_arena = decl.typed_value.most_recent.arena.?.promote(module.gpa);
|
||||
defer decl.typed_value.most_recent.arena.?.* = decl_arena.state;
|
||||
log.debug("analyze liveness of {s}\n", .{decl.name});
|
||||
log.debug("analyze liveness of {s}", .{decl.name});
|
||||
try liveness.analyze(module.gpa, &decl_arena.allocator, func.body);
|
||||
|
||||
if (std.builtin.mode == .Debug and self.verbose_ir) {
|
||||
|
||||
@ -547,9 +547,12 @@ fn analyzeInstStr(mod: *Module, scope: *Scope, str_inst: *zir.Inst.Str) InnerErr
|
||||
errdefer new_decl_arena.deinit();
|
||||
const arena_bytes = try new_decl_arena.allocator.dupe(u8, str_inst.positionals.bytes);
|
||||
|
||||
const decl_ty = try Type.Tag.array_u8_sentinel_0.create(&new_decl_arena.allocator, arena_bytes.len);
|
||||
const decl_val = try Value.Tag.bytes.create(&new_decl_arena.allocator, arena_bytes);
|
||||
|
||||
const new_decl = try mod.createAnonymousDecl(scope, &new_decl_arena, .{
|
||||
.ty = try Type.Tag.array_u8_sentinel_0.create(scope.arena(), arena_bytes.len),
|
||||
.val = try Value.Tag.bytes.create(scope.arena(), arena_bytes),
|
||||
.ty = decl_ty,
|
||||
.val = decl_val,
|
||||
});
|
||||
return mod.analyzeDeclRef(scope, str_inst.base.src, new_decl);
|
||||
}
|
||||
@ -1079,7 +1082,7 @@ fn analyzeInstErrorSet(mod: *Module, scope: *Scope, inst: *zir.Inst.ErrorSet) In
|
||||
var new_decl_arena = std.heap.ArenaAllocator.init(mod.gpa);
|
||||
errdefer new_decl_arena.deinit();
|
||||
|
||||
const payload = try scope.arena().create(Value.Payload.ErrorSet);
|
||||
const payload = try new_decl_arena.allocator.create(Value.Payload.ErrorSet);
|
||||
payload.* = .{
|
||||
.base = .{ .tag = .error_set },
|
||||
.data = .{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user