| author | |
| committer | |
| log | 7a0948253636080e5abe59b938761ee7348a7025 |
| tree | a8e49c415952acc8c2280bc8e1c46d19ce27bcd3 |
| parent | 677eaf29b10df9b1dc461b37e7be78734b11ef19 |
closes #10582 files changed, 18 insertions(+), 0 deletions(-)
src/analyze.cpp+2| ... | @@ -1018,6 +1018,8 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) { | ... | @@ -1018,6 +1018,8 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) { |
| 1018 | } | 1018 | } |
| 1019 | if (fn_type_id->return_type != nullptr) { | 1019 | if (fn_type_id->return_type != nullptr) { |
| 1020 | ensure_complete_type(g, fn_type_id->return_type); | 1020 | ensure_complete_type(g, fn_type_id->return_type); |
| 1021 | if (type_is_invalid(fn_type_id->return_type)) | ||
| 1022 | return g->builtin_types.entry_invalid; | ||
| 1021 | } else { | 1023 | } else { |
| 1022 | zig_panic("TODO implement inferred return types https://github.com/ziglang/zig/issues/447"); | 1024 | zig_panic("TODO implement inferred return types https://github.com/ziglang/zig/issues/447"); |
| 1023 | } | 1025 | } |
test/compile_errors.zig+16| ... | @@ -1,6 +1,22 @@ | ... | @@ -1,6 +1,22 @@ |
| 1 | const tests = @import("tests.zig"); | 1 | const tests = @import("tests.zig"); |
| 2 | 2 | ||
| 3 | pub fn addCases(cases: *tests.CompileErrorContext) void { | 3 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 4 | cases.add( | ||
| 5 | "error when evaluating return type", | ||
| 6 | \\const Foo = struct { | ||
| 7 | \\ map: i32(i32), | ||
| 8 | \\ | ||
| 9 | \\ fn init() Foo { | ||
| 10 | \\ return undefined; | ||
| 11 | \\ } | ||
| 12 | \\}; | ||
| 13 | \\export fn entry() void { | ||
| 14 | \\ var rule_set = try Foo.init(); | ||
| 15 | \\} | ||
| 16 | , | ||
| 17 | ".tmp_source.zig:2:13: error: invalid cast from type 'type' to 'i32'", | ||
| 18 | ); | ||
| 19 | |||
| 4 | cases.add( | 20 | cases.add( |
| 5 | "slicing single-item pointer", | 21 | "slicing single-item pointer", |
| 6 | \\export fn entry(ptr: *i32) void { | 22 | \\export fn entry(ptr: *i32) void { |