authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-03-12 20:25:54+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-03-14 07:40:08+00:00
log347196f905c083047fdc0a3b72656f1867973a13
tree70f7ba3c98fc67589bf26decc445e308b041adcc
parent075c103332effdac80d2c00e59f06ee0fea95b49
signaturelock-open Commit is signed but in an unrecognized format.

Zcu: perform orphan checks against uncoerced function


2 files changed, 8 insertions(+), 3 deletions(-)

src/InternPool.zig+1-1
......@@ -9223,7 +9223,7 @@ pub fn funcTypeParamsLen(ip: *const InternPool, i: Index) u32 {
92239223 return ip.extra.items[start + std.meta.fieldIndex(Tag.TypeFunction, "params_len").?];
92249224}
92259225
9226fn unwrapCoercedFunc(ip: *const InternPool, i: Index) Index {
9226pub fn unwrapCoercedFunc(ip: *const InternPool, i: Index) Index {
92279227 const tags = ip.items.items(.tag);
92289228 return switch (tags[@intFromEnum(i)]) {
92299229 .func_coerced => {
src/Module.zig+7-2
......@@ -3113,13 +3113,18 @@ pub fn ensureDeclAnalyzed(mod: *Module, decl_index: Decl.Index) SemaError!void {
31133113 }
31143114}
31153115
3116pub fn ensureFuncBodyAnalyzed(zcu: *Zcu, func_index: InternPool.Index) SemaError!void {
3116pub fn ensureFuncBodyAnalyzed(zcu: *Zcu, maybe_coerced_func_index: InternPool.Index) SemaError!void {
31173117 const tracy = trace(@src());
31183118 defer tracy.end();
31193119
31203120 const gpa = zcu.gpa;
31213121 const ip = &zcu.intern_pool;
3122 const func = zcu.funcInfo(func_index);
3122
3123 // We only care about the uncoerced function.
3124 // We need to do this for the "orphaned function" check below to be valid.
3125 const func_index = ip.unwrapCoercedFunc(maybe_coerced_func_index);
3126
3127 const func = zcu.funcInfo(maybe_coerced_func_index);
31233128 const decl_index = func.owner_decl;
31243129 const decl = zcu.declPtr(decl_index);
31253130