| author | |
| committer | |
| log | c87920966133d3285b60ccd022282e3f53789e0c |
| tree | f8991e5faf1bfa4ebfb943bb0e20b13ccdacad56 |
| parent | e444e737b786afd0c5aba2ea04c901f89c57813e |
| signature | Commit is signed but in an unrecognized format. |
2 files changed, 17 insertions(+), 1 deletions(-)
src/analyze.cpp+5-1| ... | @@ -5177,7 +5177,11 @@ static Error resolve_coro_frame(CodeGen *g, ZigType *frame_type) { | ... | @@ -5177,7 +5177,11 @@ static Error resolve_coro_frame(CodeGen *g, ZigType *frame_type) { |
| 5177 | for (size_t i = 0; i < fn->call_list.length; i += 1) { | 5177 | for (size_t i = 0; i < fn->call_list.length; i += 1) { |
| 5178 | IrInstructionCallGen *call = fn->call_list.at(i); | 5178 | IrInstructionCallGen *call = fn->call_list.at(i); |
| 5179 | ZigFn *callee = call->fn_entry; | 5179 | ZigFn *callee = call->fn_entry; |
| 5180 | assert(callee != nullptr); | 5180 | if (callee == nullptr) { |
| 5181 | add_node_error(g, call->base.source_node, | ||
| 5182 | buf_sprintf("function is not comptime-known; @asyncCall required")); | ||
| 5183 | return ErrorSemanticAnalyzeFail; | ||
| 5184 | } | ||
| 5181 | 5185 | ||
| 5182 | analyze_fn_body(g, callee); | 5186 | analyze_fn_body(g, callee); |
| 5183 | if (callee->anal_state == FnAnalStateInvalid) { | 5187 | if (callee->anal_state == FnAnalStateInvalid) { |
test/compile_errors.zig+12| ... | @@ -2,6 +2,18 @@ const tests = @import("tests.zig"); | ... | @@ -2,6 +2,18 @@ const tests = @import("tests.zig"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | 3 | ||
| 4 | pub fn addCases(cases: *tests.CompileErrorContext) void { | 4 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5 | cases.add( | ||
| 6 | "runtime-known async function called", | ||
| 7 | \\export fn entry() void { | ||
| 8 | \\ var ptr = afunc; | ||
| 9 | \\ _ = ptr(); | ||
| 10 | \\} | ||
| 11 | \\ | ||
| 12 | \\async fn afunc() void {} | ||
| 13 | , | ||
| 14 | "tmp.zig:3:12: error: function is not comptime-known; @asyncCall required", | ||
| 15 | ); | ||
| 16 | |||
| 5 | cases.add( | 17 | cases.add( |
| 6 | "runtime-known function called with async keyword", | 18 | "runtime-known function called with async keyword", |
| 7 | \\export fn entry() void { | 19 | \\export fn entry() void { |