mirror of
https://github.com/ziglang/zig.git
synced 2026-01-21 06:45:24 +00:00
Type: check return_type for generic poison before comparing
Closes #13423
This commit is contained in:
parent
cacfb0cfe4
commit
c4465556fd
@ -640,7 +640,9 @@ pub const Type = extern union {
|
||||
const a_info = a.fnInfo();
|
||||
const b_info = b.fnInfo();
|
||||
|
||||
if (!eql(a_info.return_type, b_info.return_type, mod))
|
||||
if (a_info.return_type.tag() != .generic_poison and
|
||||
b_info.return_type.tag() != .generic_poison and
|
||||
!eql(a_info.return_type, b_info.return_type, mod))
|
||||
return false;
|
||||
|
||||
if (a_info.is_var_args != b_info.is_var_args)
|
||||
|
||||
@ -405,3 +405,15 @@ test "null sentinel pointer passed as generic argument" {
|
||||
};
|
||||
try S.doTheTest((@intToPtr([*:null]const [*c]const u8, 8)));
|
||||
}
|
||||
|
||||
test "generic function passed as comptime argument" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
|
||||
const S = struct {
|
||||
fn doMath(comptime f: fn (type, i32, i32) error{Overflow}!i32, a: i32, b: i32) !void {
|
||||
const result = try f(i32, a, b);
|
||||
try expect(result == 11);
|
||||
}
|
||||
};
|
||||
try S.doMath(std.math.add, 5, 6);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user