aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-06-01 22:20:26 -0400
committerAndrew Kelley <andrew@ziglang.org>2023-06-10 20:47:59 -0700
commitfdfe730487972f089786938706f311b1f8631333 (patch)
treebe18d28d24c5ab1f4d5f73e64ee213ca2099aceb /src/Sema.zig
parentbc3b56f957d950edb6fde3585f8e9f4dda009d3e (diff)
downloadzig-fdfe730487972f089786938706f311b1f8631333.tar.gz
zig-fdfe730487972f089786938706f311b1f8631333.zip
InternPool: fix more key lifetime issues
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 3585c106eb..794638ea43 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -7685,8 +7685,7 @@ fn instantiateGenericCall(
// Make a runtime call to the new function, making sure to omit the comptime args.
const comptime_args = callee.comptime_args.?;
const func_ty = mod.declPtr(callee.owner_decl).ty;
- const new_fn_info = mod.typeToFunc(func_ty).?;
- const runtime_args_len = @intCast(u32, new_fn_info.param_types.len);
+ const runtime_args_len = @intCast(u32, mod.typeToFunc(func_ty).?.param_types.len);
const runtime_args = try sema.arena.alloc(Air.Inst.Ref, runtime_args_len);
{
var runtime_i: u32 = 0;
@@ -7702,7 +7701,7 @@ fn instantiateGenericCall(
uncasted_args[total_i],
comptime_args[total_i],
runtime_args,
- new_fn_info,
+ mod.typeToFunc(func_ty).?,
&runtime_i,
) catch |err| switch (err) {
error.NeededSourceLocation => {
@@ -7713,7 +7712,7 @@ fn instantiateGenericCall(
uncasted_args[total_i],
comptime_args[total_i],
runtime_args,
- new_fn_info,
+ mod.typeToFunc(func_ty).?,
&runtime_i,
);
unreachable;
@@ -7723,12 +7722,12 @@ fn instantiateGenericCall(
total_i += 1;
}
- try sema.queueFullTypeResolution(new_fn_info.return_type.toType());
+ try sema.queueFullTypeResolution(mod.typeToFunc(func_ty).?.return_type.toType());
}
if (call_dbg_node) |some| try sema.zirDbgStmt(block, some);
- if (sema.owner_func != null and new_fn_info.return_type.toType().isError(mod)) {
+ if (sema.owner_func != null and mod.typeToFunc(func_ty).?.return_type.toType().isError(mod)) {
sema.owner_func.?.calls_or_awaits_errorable_fn = true;
}
@@ -16346,10 +16345,9 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
// Optional value is only null if anyerror
// Value can be zero-length slice otherwise
const error_field_vals = if (ty.isAnyError(mod)) null else blk: {
- const names = ty.errorSetNames(mod);
- const vals = try sema.arena.alloc(InternPool.Index, names.len);
- for (vals, names) |*field_val, name_ip| {
- const name = ip.stringToSlice(name_ip);
+ const vals = try sema.arena.alloc(InternPool.Index, ty.errorSetNames(mod).len);
+ for (vals, 0..) |*field_val, i| {
+ const name = ip.stringToSlice(ty.errorSetNames(mod)[i]);
const name_val = v: {
var anon_decl = try block.startAnonDecl();
defer anon_decl.deinit();