diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-08-17 16:49:23 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-08-17 16:49:23 -0400 |
| commit | 66a490c27c01c958d8d20dbc289c6b2b934a724e (patch) | |
| tree | edd444dfae7eb106453f9aa0aa9ec3908c97e2f1 /src/analyze.cpp | |
| parent | 0ff396c34f93b60a000e1ee50e881a8c25122b79 (diff) | |
| download | zig-66a490c27c01c958d8d20dbc289c6b2b934a724e.tar.gz zig-66a490c27c01c958d8d20dbc289c6b2b934a724e.zip | |
detect non-async function pointer of inferred async function
closes #3075
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 4aff6da8e9..16e66a5906 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -4144,8 +4144,15 @@ void semantic_analyze(CodeGen *g) { // second pass over functions for detecting async for (g->fn_defs_index = 0; g->fn_defs_index < g->fn_defs.length; g->fn_defs_index += 1) { - ZigFn *fn_entry = g->fn_defs.at(g->fn_defs_index); - analyze_fn_async(g, fn_entry, true); + ZigFn *fn = g->fn_defs.at(g->fn_defs_index); + analyze_fn_async(g, fn, true); + if (fn_is_async(fn) && fn->non_async_node != nullptr) { + ErrorMsg *msg = add_node_error(g, fn->proto_node, + buf_sprintf("'%s' cannot be async", buf_ptr(&fn->symbol_name))); + add_error_note(g, msg, fn->non_async_node, + buf_sprintf("required to be non-async here")); + add_async_error_notes(g, msg, fn); + } } } |
