parent
4c87281b5c
commit
50754ba336
|
@ -5289,7 +5289,10 @@ static uint32_t hash_const_val(ZigValue *const_val) {
|
|||
case ZigTypeIdAnyFrame:
|
||||
// TODO better hashing algorithm
|
||||
return 3747294894;
|
||||
case ZigTypeIdBoundFn:
|
||||
case ZigTypeIdBoundFn: {
|
||||
assert(const_val->data.x_bound_fn.fn != nullptr);
|
||||
return 3677364617 ^ hash_ptr(const_val->data.x_bound_fn.fn);
|
||||
}
|
||||
case ZigTypeIdInvalid:
|
||||
case ZigTypeIdUnreachable:
|
||||
zig_unreachable();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
const std = @import("std");
|
||||
const expect = std.testing.expect;
|
||||
const expectEqual = std.testing.expectEqual;
|
||||
|
||||
test "basic invocations" {
|
||||
const foo = struct {
|
||||
|
@ -53,3 +54,21 @@ test "tuple parameters" {
|
|||
expect(@call(.{ .modifier = .always_inline }, add, separate_args3) == 46);
|
||||
}
|
||||
}
|
||||
|
||||
test "comptime call with bound function as parameter" {
|
||||
const S = struct {
|
||||
fn ReturnType(func: var) type {
|
||||
return switch (@typeInfo(@TypeOf(func))) {
|
||||
.BoundFn => |info| info,
|
||||
else => unreachable,
|
||||
}.return_type orelse void;
|
||||
}
|
||||
|
||||
fn call_me_maybe() ?i32 {
|
||||
return 123;
|
||||
}
|
||||
};
|
||||
|
||||
var inst: S = undefined;
|
||||
expectEqual(?i32, S.ReturnType(inst.call_me_maybe));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue