authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-27 17:31:06-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-28 15:10:48-04:00
log4f594527c02985272d61c198d7c5aafa7d777e50
tree0516075056d80bfc01ee779288aad90c9350b0f6
parenta3222b5ff1d6698e3e72890276900de34c85d11d
signaturelock-open Commit is signed but in an unrecognized format.

detect async fn recursion and emit compile error


2 files changed, 8 insertions(+), 0 deletions(-)

src/analyze.cpp+7
......@@ -4398,6 +4398,7 @@ static Error analyze_callee_async(CodeGen *g, ZigFn *fn, ZigFn *callee, AstNode
43984398 }
43994399 }
44004400 if (callee_is_async) {
4401 bool bad_recursion = (fn->inferred_async_node == inferred_async_none);
44014402 fn->inferred_async_node = call_node;
44024403 fn->inferred_async_fn = callee;
44034404 if (must_not_be_async) {
......@@ -4407,6 +4408,12 @@ static Error analyze_callee_async(CodeGen *g, ZigFn *fn, ZigFn *callee, AstNode
44074408 add_async_error_notes(g, msg, fn);
44084409 return ErrorSemanticAnalyzeFail;
44094410 }
4411 if (bad_recursion) {
4412 ErrorMsg *msg = add_node_error(g, fn->proto_node,
4413 buf_sprintf("recursive function cannot be async"));
4414 add_async_error_notes(g, msg, fn);
4415 return ErrorSemanticAnalyzeFail;
4416 }
44104417 if (fn->assumed_non_async != nullptr) {
44114418 ErrorMsg *msg = add_node_error(g, fn->proto_node,
44124419 buf_sprintf("unable to infer whether '%s' should be async",
src/codegen.cpp+1
......@@ -3917,6 +3917,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
39173917 if (instruction->modifier == CallModifierAsync) {
39183918 frame_result_loc = result_loc;
39193919 } else {
3920 src_assert(instruction->frame_result_loc != nullptr, instruction->base.source_node);
39203921 frame_result_loc_uncasted = ir_llvm_value(g, instruction->frame_result_loc);
39213922 src_assert(instruction->fn_entry != nullptr, instruction->base.source_node);
39223923 frame_result_loc = LLVMBuildBitCast(g->builder, frame_result_loc_uncasted,