fix false negative determining if function is generic
This solves the smaller test case of #1421 but the other test case is still an assertion failure.
This commit is contained in:
parent
68e2794e15
commit
526d8425ab
|
@ -1575,7 +1575,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
|
|||
|
||||
switch (type_entry->id) {
|
||||
case TypeTableEntryIdInvalid:
|
||||
return g->builtin_types.entry_invalid;
|
||||
zig_unreachable();
|
||||
case TypeTableEntryIdUnreachable:
|
||||
case TypeTableEntryIdUndefined:
|
||||
case TypeTableEntryIdNull:
|
||||
|
@ -1703,6 +1703,11 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
|
|||
case TypeTableEntryIdUnion:
|
||||
case TypeTableEntryIdFn:
|
||||
case TypeTableEntryIdPromise:
|
||||
if ((err = type_ensure_zero_bits_known(g, fn_type_id.return_type)))
|
||||
return g->builtin_types.entry_invalid;
|
||||
if (type_requires_comptime(fn_type_id.return_type)) {
|
||||
return get_generic_fn_type(g, &fn_type_id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ comptime {
|
|||
_ = @import("cases/bugs/1111.zig");
|
||||
_ = @import("cases/bugs/1230.zig");
|
||||
_ = @import("cases/bugs/1277.zig");
|
||||
_ = @import("cases/bugs/1421.zig");
|
||||
_ = @import("cases/bugs/394.zig");
|
||||
_ = @import("cases/bugs/655.zig");
|
||||
_ = @import("cases/bugs/656.zig");
|
||||
|
|
14
test/cases/bugs/1421.zig
Normal file
14
test/cases/bugs/1421.zig
Normal file
|
@ -0,0 +1,14 @@
|
|||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const S = struct {
|
||||
fn method() builtin.TypeInfo {
|
||||
return @typeInfo(S);
|
||||
}
|
||||
};
|
||||
|
||||
test "functions with return type required to be comptime are generic" {
|
||||
const ti = S.method();
|
||||
assert(builtin.TypeId(ti) == builtin.TypeId.Struct);
|
||||
}
|
Loading…
Reference in New Issue
Block a user