authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-06-01 22:20:26-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:47:59-07:00
logfdfe730487972f089786938706f311b1f8631333
treebe18d28d24c5ab1f4d5f73e64ee213ca2099aceb
parentbc3b56f957d950edb6fde3585f8e9f4dda009d3e

InternPool: fix more key lifetime issues


1 files changed, 8 insertions(+), 10 deletions(-)

src/Sema.zig+8-10
......@@ -7685,8 +7685,7 @@ fn instantiateGenericCall(
76857685 // Make a runtime call to the new function, making sure to omit the comptime args.
76867686 const comptime_args = callee.comptime_args.?;
76877687 const func_ty = mod.declPtr(callee.owner_decl).ty;
7688 const new_fn_info = mod.typeToFunc(func_ty).?;
7689 const runtime_args_len = @intCast(u32, new_fn_info.param_types.len);
7688 const runtime_args_len = @intCast(u32, mod.typeToFunc(func_ty).?.param_types.len);
76907689 const runtime_args = try sema.arena.alloc(Air.Inst.Ref, runtime_args_len);
76917690 {
76927691 var runtime_i: u32 = 0;
......@@ -7702,7 +7701,7 @@ fn instantiateGenericCall(
77027701 uncasted_args[total_i],
77037702 comptime_args[total_i],
77047703 runtime_args,
7705 new_fn_info,
7704 mod.typeToFunc(func_ty).?,
77067705 &runtime_i,
77077706 ) catch |err| switch (err) {
77087707 error.NeededSourceLocation => {
......@@ -7713,7 +7712,7 @@ fn instantiateGenericCall(
77137712 uncasted_args[total_i],
77147713 comptime_args[total_i],
77157714 runtime_args,
7716 new_fn_info,
7715 mod.typeToFunc(func_ty).?,
77177716 &runtime_i,
77187717 );
77197718 unreachable;
......@@ -7723,12 +7722,12 @@ fn instantiateGenericCall(
77237722 total_i += 1;
77247723 }
77257724
7726 try sema.queueFullTypeResolution(new_fn_info.return_type.toType());
7725 try sema.queueFullTypeResolution(mod.typeToFunc(func_ty).?.return_type.toType());
77277726 }
77287727
77297728 if (call_dbg_node) |some| try sema.zirDbgStmt(block, some);
77307729
7731 if (sema.owner_func != null and new_fn_info.return_type.toType().isError(mod)) {
7730 if (sema.owner_func != null and mod.typeToFunc(func_ty).?.return_type.toType().isError(mod)) {
77327731 sema.owner_func.?.calls_or_awaits_errorable_fn = true;
77337732 }
77347733
......@@ -16346,10 +16345,9 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1634616345 // Optional value is only null if anyerror
1634716346 // Value can be zero-length slice otherwise
1634816347 const error_field_vals = if (ty.isAnyError(mod)) null else blk: {
16349 const names = ty.errorSetNames(mod);
16350 const vals = try sema.arena.alloc(InternPool.Index, names.len);
16351 for (vals, names) |*field_val, name_ip| {
16352 const name = ip.stringToSlice(name_ip);
16348 const vals = try sema.arena.alloc(InternPool.Index, ty.errorSetNames(mod).len);
16349 for (vals, 0..) |*field_val, i| {
16350 const name = ip.stringToSlice(ty.errorSetNames(mod)[i]);
1635316351 const name_val = v: {
1635416352 var anon_decl = try block.startAnonDecl();
1635516353 defer anon_decl.deinit();