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(...@@ -7685,8 +7685,7 @@ fn instantiateGenericCall(
7685 // Make a runtime call to the new function, making sure to omit the comptime args.7685 // Make a runtime call to the new function, making sure to omit the comptime args.
7686 const comptime_args = callee.comptime_args.?;7686 const comptime_args = callee.comptime_args.?;
7687 const func_ty = mod.declPtr(callee.owner_decl).ty;7687 const func_ty = mod.declPtr(callee.owner_decl).ty;
7688 const new_fn_info = mod.typeToFunc(func_ty).?;7688 const runtime_args_len = @intCast(u32, mod.typeToFunc(func_ty).?.param_types.len);
7689 const runtime_args_len = @intCast(u32, new_fn_info.param_types.len);
7690 const runtime_args = try sema.arena.alloc(Air.Inst.Ref, runtime_args_len);7689 const runtime_args = try sema.arena.alloc(Air.Inst.Ref, runtime_args_len);
7691 {7690 {
7692 var runtime_i: u32 = 0;7691 var runtime_i: u32 = 0;
...@@ -7702,7 +7701,7 @@ fn instantiateGenericCall(...@@ -7702,7 +7701,7 @@ fn instantiateGenericCall(
7702 uncasted_args[total_i],7701 uncasted_args[total_i],
7703 comptime_args[total_i],7702 comptime_args[total_i],
7704 runtime_args,7703 runtime_args,
7705 new_fn_info,7704 mod.typeToFunc(func_ty).?,
7706 &runtime_i,7705 &runtime_i,
7707 ) catch |err| switch (err) {7706 ) catch |err| switch (err) {
7708 error.NeededSourceLocation => {7707 error.NeededSourceLocation => {
...@@ -7713,7 +7712,7 @@ fn instantiateGenericCall(...@@ -7713,7 +7712,7 @@ fn instantiateGenericCall(
7713 uncasted_args[total_i],7712 uncasted_args[total_i],
7714 comptime_args[total_i],7713 comptime_args[total_i],
7715 runtime_args,7714 runtime_args,
7716 new_fn_info,7715 mod.typeToFunc(func_ty).?,
7717 &runtime_i,7716 &runtime_i,
7718 );7717 );
7719 unreachable;7718 unreachable;
...@@ -7723,12 +7722,12 @@ fn instantiateGenericCall(...@@ -7723,12 +7722,12 @@ fn instantiateGenericCall(
7723 total_i += 1;7722 total_i += 1;
7724 }7723 }
77257724
7726 try sema.queueFullTypeResolution(new_fn_info.return_type.toType());7725 try sema.queueFullTypeResolution(mod.typeToFunc(func_ty).?.return_type.toType());
7727 }7726 }
77287727
7729 if (call_dbg_node) |some| try sema.zirDbgStmt(block, some);7728 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)) {
7732 sema.owner_func.?.calls_or_awaits_errorable_fn = true;7731 sema.owner_func.?.calls_or_awaits_errorable_fn = true;
7733 }7732 }
77347733
...@@ -16346,10 +16345,9 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -16346,10 +16345,9 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
16346 // Optional value is only null if anyerror16345 // Optional value is only null if anyerror
16347 // Value can be zero-length slice otherwise16346 // Value can be zero-length slice otherwise
16348 const error_field_vals = if (ty.isAnyError(mod)) null else blk: {16347 const error_field_vals = if (ty.isAnyError(mod)) null else blk: {
16349 const names = ty.errorSetNames(mod);16348 const vals = try sema.arena.alloc(InternPool.Index, ty.errorSetNames(mod).len);
16350 const vals = try sema.arena.alloc(InternPool.Index, names.len);16349 for (vals, 0..) |*field_val, i| {
16351 for (vals, names) |*field_val, name_ip| {16350 const name = ip.stringToSlice(ty.errorSetNames(mod)[i]);
16352 const name = ip.stringToSlice(name_ip);
16353 const name_val = v: {16351 const name_val = v: {
16354 var anon_decl = try block.startAnonDecl();16352 var anon_decl = try block.startAnonDecl();
16355 defer anon_decl.deinit();16353 defer anon_decl.deinit();