aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-08-29 22:44:07 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-08-29 22:44:07 -0400
commite9a4bcbcc6ac89c5526a6baaf2b0df49d0577eb4 (patch)
tree1c8b6c29b99f0cc7f22307674dd58634b1910d12 /src/analyze.cpp
parent03910925f06f6127e81de47ff22ce4d24ca565b2 (diff)
downloadzig-e9a4bcbcc6ac89c5526a6baaf2b0df49d0577eb4.tar.gz
zig-e9a4bcbcc6ac89c5526a6baaf2b0df49d0577eb4.zip
fix regressions
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index d1c79f9a1a..0bc42cc971 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -4174,8 +4174,14 @@ static void add_async_error_notes(CodeGen *g, ErrorMsg *msg, ZigFn *fn) {
assert(fn->inferred_async_node != inferred_async_checking);
assert(fn->inferred_async_node != inferred_async_none);
if (fn->inferred_async_fn != nullptr) {
- ErrorMsg *new_msg = add_error_note(g, msg, fn->inferred_async_node,
- buf_sprintf("async function call here"));
+ ErrorMsg *new_msg;
+ if (fn->inferred_async_node->type == NodeTypeAwaitExpr) {
+ new_msg = add_error_note(g, msg, fn->inferred_async_node,
+ buf_create_from_str("await here is a suspend point"));
+ } else {
+ new_msg = add_error_note(g, msg, fn->inferred_async_node,
+ buf_sprintf("async function call here"));
+ }
return add_async_error_notes(g, new_msg, fn->inferred_async_fn);
} else if (fn->inferred_async_node->type == NodeTypeFnProto) {
add_error_note(g, msg, fn->inferred_async_node,
@@ -4185,7 +4191,7 @@ static void add_async_error_notes(CodeGen *g, ErrorMsg *msg, ZigFn *fn) {
buf_sprintf("suspends here"));
} else if (fn->inferred_async_node->type == NodeTypeAwaitExpr) {
add_error_note(g, msg, fn->inferred_async_node,
- buf_sprintf("await is a suspend point"));
+ buf_sprintf("await here is a suspend point"));
} else if (fn->inferred_async_node->type == NodeTypeFnCallExpr &&
fn->inferred_async_node->data.fn_call_expr.is_builtin)
{
@@ -4240,6 +4246,16 @@ static Error analyze_callee_async(CodeGen *g, ZigFn *fn, ZigFn *callee, AstNode
add_async_error_notes(g, msg, fn);
return ErrorSemanticAnalyzeFail;
}
+ if (fn->assumed_non_async != nullptr) {
+ ErrorMsg *msg = add_node_error(g, fn->proto_node,
+ buf_sprintf("unable to infer whether '%s' should be async",
+ buf_ptr(&fn->symbol_name)));
+ add_error_note(g, msg, fn->assumed_non_async,
+ buf_sprintf("assumed to be non-async here"));
+ add_async_error_notes(g, msg, fn);
+ fn->anal_state = FnAnalStateInvalid;
+ return ErrorSemanticAnalyzeFail;
+ }
return ErrorIsAsync;
}
return ErrorNone;