detect async fn recursion and emit compile error
parent
a3222b5ff1
commit
4f594527c0
|
@ -4398,6 +4398,7 @@ static Error analyze_callee_async(CodeGen *g, ZigFn *fn, ZigFn *callee, AstNode
|
|||
}
|
||||
}
|
||||
if (callee_is_async) {
|
||||
bool bad_recursion = (fn->inferred_async_node == inferred_async_none);
|
||||
fn->inferred_async_node = call_node;
|
||||
fn->inferred_async_fn = callee;
|
||||
if (must_not_be_async) {
|
||||
|
@ -4407,6 +4408,12 @@ static Error analyze_callee_async(CodeGen *g, ZigFn *fn, ZigFn *callee, AstNode
|
|||
add_async_error_notes(g, msg, fn);
|
||||
return ErrorSemanticAnalyzeFail;
|
||||
}
|
||||
if (bad_recursion) {
|
||||
ErrorMsg *msg = add_node_error(g, fn->proto_node,
|
||||
buf_sprintf("recursive function cannot be async"));
|
||||
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",
|
||||
|
|
|
@ -3917,6 +3917,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
|
|||
if (instruction->modifier == CallModifierAsync) {
|
||||
frame_result_loc = result_loc;
|
||||
} else {
|
||||
src_assert(instruction->frame_result_loc != nullptr, instruction->base.source_node);
|
||||
frame_result_loc_uncasted = ir_llvm_value(g, instruction->frame_result_loc);
|
||||
src_assert(instruction->fn_entry != nullptr, instruction->base.source_node);
|
||||
frame_result_loc = LLVMBuildBitCast(g->builder, frame_result_loc_uncasted,
|
||||
|
|
Loading…
Reference in New Issue