diff --git a/src/InternPool.zig b/src/InternPool.zig index be6e45441e55ec373e533643786528d0abeb310c..fc4c4ebec11646d461ebc585cb7fcaa85e99371e 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -10165,8 +10165,8 @@ pub fn getCoerced( val_item.data + std.meta.fieldIndex(Tag.FuncCoerced, "func").? ]); switch (func.unwrap(ip).getTag(ip)) { - .func_decl => return getCoercedFuncDecl(ip, gpa, io, tid, val, new_ty), - .func_instance => return getCoercedFuncInstance(ip, gpa, io, tid, val, new_ty), + .func_decl => return getCoercedFuncDecl(ip, gpa, io, tid, func, new_ty), + .func_instance => return getCoercedFuncInstance(ip, gpa, io, tid, func, new_ty), else => unreachable, } }, diff --git a/test/behavior/cast.zig b/test/behavior/cast.zig index 41b53fdbbb0f17e9f27264eeaebcf4e376a68cfc..178c95de4037cc415d0caefd89e35baed3455cb8 100644 --- a/test/behavior/cast.zig +++ b/test/behavior/cast.zig @@ -3153,3 +3153,19 @@ test "coerce enum to union with zero-bit fields through local variables" { try expect(result == .foo); } + +test "coercing a coerced function" { + const S = struct { + fn doTheTest() !void { + const bar: fn (anytype, anytype) void = foo; + higherOrder(1, bar); + } + + fn foo(_: anytype, _: void) void {} + + fn higherOrder(x: anytype, f: fn (@TypeOf(x), void) void) void { + _ = f(x, {}); + } + }; + try S.doTheTest(); +}