| author | |
| committer | |
| log | 526d8425abf91b33e828b964f7d55d70e17780bf |
| tree | b19d4b1a31d66d6a1f30f32506249c016b6e0e9b |
| parent | 68e2794e1543f91ab8f984127018820897cc0521 |
| signature |
This solves the smaller test case of #1421 but the
other test case is still an assertion failure.3 files changed, 21 insertions(+), 1 deletions(-)
src/analyze.cpp+6-1| ... | ... | @@ -1575,7 +1575,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c |
| 1575 | 1575 | |
| 1576 | 1576 | switch (type_entry->id) { |
| 1577 | 1577 | case TypeTableEntryIdInvalid: |
| 1578 | return g->builtin_types.entry_invalid; | |
| 1578 | zig_unreachable(); | |
| 1579 | 1579 | case TypeTableEntryIdUnreachable: |
| 1580 | 1580 | case TypeTableEntryIdUndefined: |
| 1581 | 1581 | case TypeTableEntryIdNull: |
| ... | ... | @@ -1703,6 +1703,11 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c |
| 1703 | 1703 | case TypeTableEntryIdUnion: |
| 1704 | 1704 | case TypeTableEntryIdFn: |
| 1705 | 1705 | case TypeTableEntryIdPromise: |
| 1706 | if ((err = type_ensure_zero_bits_known(g, fn_type_id.return_type))) | |
| 1707 | return g->builtin_types.entry_invalid; | |
| 1708 | if (type_requires_comptime(fn_type_id.return_type)) { | |
| 1709 | return get_generic_fn_type(g, &fn_type_id); | |
| 1710 | } | |
| 1706 | 1711 | break; |
| 1707 | 1712 | } |
| 1708 | 1713 |
test/behavior.zig+1| ... | ... | @@ -11,6 +11,7 @@ comptime { |
| 11 | 11 | _ = @import("cases/bugs/1111.zig"); |
| 12 | 12 | _ = @import("cases/bugs/1230.zig"); |
| 13 | 13 | _ = @import("cases/bugs/1277.zig"); |
| 14 | _ = @import("cases/bugs/1421.zig"); | |
| 14 | 15 | _ = @import("cases/bugs/394.zig"); |
| 15 | 16 | _ = @import("cases/bugs/655.zig"); |
| 16 | 17 | _ = @import("cases/bugs/656.zig"); |
test/cases/bugs/1421.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | const std = @import("std"); | |
| 2 | const builtin = @import("builtin"); | |
| 3 | const assert = std.debug.assert; | |
| 4 | ||
| 5 | const S = struct { | |
| 6 | fn method() builtin.TypeInfo { | |
| 7 | return @typeInfo(S); | |
| 8 | } | |
| 9 | }; | |
| 10 | ||
| 11 | test "functions with return type required to be comptime are generic" { | |
| 12 | const ti = S.method(); | |
| 13 | assert(builtin.TypeId(ti) == builtin.TypeId.Struct); | |
| 14 | } |