| ... | @@ -3893,18 +3893,18 @@ static void analyze_fn_async(CodeGen *g, ZigFn *fn) { | ... | @@ -3893,18 +3893,18 @@ static void analyze_fn_async(CodeGen *g, ZigFn *fn) { |
| 3893 | fn->inferred_async_node = inferred_async_none; | 3893 | fn->inferred_async_node = inferred_async_none; |
| 3894 | } | 3894 | } |
| 3895 | | 3895 | |
| 3896 | static void analyze_fn_ir(CodeGen *g, ZigFn *fn_table_entry, AstNode *return_type_node) { | 3896 | static void analyze_fn_ir(CodeGen *g, ZigFn *fn, AstNode *return_type_node) { |
| 3897 | ZigType *fn_type = fn_table_entry->type_entry; | 3897 | ZigType *fn_type = fn->type_entry; |
| 3898 | assert(!fn_type->data.fn.is_generic); | 3898 | assert(!fn_type->data.fn.is_generic); |
| 3899 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; | 3899 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; |
| 3900 | | 3900 | |
| 3901 | ZigType *block_return_type = ir_analyze(g, &fn_table_entry->ir_executable, | 3901 | ZigType *block_return_type = ir_analyze(g, &fn->ir_executable, |
| 3902 | &fn_table_entry->analyzed_executable, fn_type_id->return_type, return_type_node); | 3902 | &fn->analyzed_executable, fn_type_id->return_type, return_type_node); |
| 3903 | fn_table_entry->src_implicit_return_type = block_return_type; | 3903 | fn->src_implicit_return_type = block_return_type; |
| 3904 | | 3904 | |
| 3905 | if (type_is_invalid(block_return_type) || fn_table_entry->analyzed_executable.invalid) { | 3905 | if (type_is_invalid(block_return_type) || fn->analyzed_executable.invalid) { |
| 3906 | assert(g->errors.length > 0); | 3906 | assert(g->errors.length > 0); |
| 3907 | fn_table_entry->anal_state = FnAnalStateInvalid; | 3907 | fn->anal_state = FnAnalStateInvalid; |
| 3908 | return; | 3908 | return; |
| 3909 | } | 3909 | } |
| 3910 | | 3910 | |
| ... | @@ -3912,20 +3912,20 @@ static void analyze_fn_ir(CodeGen *g, ZigFn *fn_table_entry, AstNode *return_typ | ... | @@ -3912,20 +3912,20 @@ static void analyze_fn_ir(CodeGen *g, ZigFn *fn_table_entry, AstNode *return_typ |
| 3912 | ZigType *return_err_set_type = fn_type_id->return_type->data.error_union.err_set_type; | 3912 | ZigType *return_err_set_type = fn_type_id->return_type->data.error_union.err_set_type; |
| 3913 | if (return_err_set_type->data.error_set.infer_fn != nullptr) { | 3913 | if (return_err_set_type->data.error_set.infer_fn != nullptr) { |
| 3914 | ZigType *inferred_err_set_type; | 3914 | ZigType *inferred_err_set_type; |
| 3915 | if (fn_table_entry->src_implicit_return_type->id == ZigTypeIdErrorSet) { | 3915 | if (fn->src_implicit_return_type->id == ZigTypeIdErrorSet) { |
| 3916 | inferred_err_set_type = fn_table_entry->src_implicit_return_type; | 3916 | inferred_err_set_type = fn->src_implicit_return_type; |
| 3917 | } else if (fn_table_entry->src_implicit_return_type->id == ZigTypeIdErrorUnion) { | 3917 | } else if (fn->src_implicit_return_type->id == ZigTypeIdErrorUnion) { |
| 3918 | inferred_err_set_type = fn_table_entry->src_implicit_return_type->data.error_union.err_set_type; | 3918 | inferred_err_set_type = fn->src_implicit_return_type->data.error_union.err_set_type; |
| 3919 | } else { | 3919 | } else { |
| 3920 | add_node_error(g, return_type_node, | 3920 | add_node_error(g, return_type_node, |
| 3921 | buf_sprintf("function with inferred error set must return at least one possible error")); | 3921 | buf_sprintf("function with inferred error set must return at least one possible error")); |
| 3922 | fn_table_entry->anal_state = FnAnalStateInvalid; | 3922 | fn->anal_state = FnAnalStateInvalid; |
| 3923 | return; | 3923 | return; |
| 3924 | } | 3924 | } |
| 3925 | | 3925 | |
| 3926 | if (inferred_err_set_type->data.error_set.infer_fn != nullptr) { | 3926 | if (inferred_err_set_type->data.error_set.infer_fn != nullptr) { |
| 3927 | if (!resolve_inferred_error_set(g, inferred_err_set_type, return_type_node)) { | 3927 | if (!resolve_inferred_error_set(g, inferred_err_set_type, return_type_node)) { |
| 3928 | fn_table_entry->anal_state = FnAnalStateInvalid; | 3928 | fn->anal_state = FnAnalStateInvalid; |
| 3929 | return; | 3929 | return; |
| 3930 | } | 3930 | } |
| 3931 | } | 3931 | } |
| ... | @@ -3945,12 +3945,25 @@ static void analyze_fn_ir(CodeGen *g, ZigFn *fn_table_entry, AstNode *return_typ | ... | @@ -3945,12 +3945,25 @@ static void analyze_fn_ir(CodeGen *g, ZigFn *fn_table_entry, AstNode *return_typ |
| 3945 | } | 3945 | } |
| 3946 | } | 3946 | } |
| 3947 | | 3947 | |
| | 3948 | CallingConvention cc = fn->type_entry->data.fn.fn_type_id.cc; |
| | 3949 | if (cc != CallingConventionUnspecified && cc != CallingConventionAsync && |
| | 3950 | fn->inferred_async_node != nullptr && |
| | 3951 | fn->inferred_async_node != inferred_async_checking && |
| | 3952 | fn->inferred_async_node != inferred_async_none) |
| | 3953 | { |
| | 3954 | ErrorMsg *msg = add_node_error(g, fn->proto_node, |
| | 3955 | buf_sprintf("function with calling convention '%s' cannot be async", |
| | 3956 | calling_convention_name(cc))); |
| | 3957 | add_async_error_notes(g, msg, fn); |
| | 3958 | fn->anal_state = FnAnalStateInvalid; |
| | 3959 | } |
| | 3960 | |
| 3948 | if (g->verbose_ir) { | 3961 | if (g->verbose_ir) { |
| 3949 | fprintf(stderr, "fn %s() { // (analyzed)\n", buf_ptr(&fn_table_entry->symbol_name)); | 3962 | fprintf(stderr, "fn %s() { // (analyzed)\n", buf_ptr(&fn->symbol_name)); |
| 3950 | ir_print(g, stderr, &fn_table_entry->analyzed_executable, 4); | 3963 | ir_print(g, stderr, &fn->analyzed_executable, 4); |
| 3951 | fprintf(stderr, "}\n"); | 3964 | fprintf(stderr, "}\n"); |
| 3952 | } | 3965 | } |
| 3953 | fn_table_entry->anal_state = FnAnalStateComplete; | 3966 | fn->anal_state = FnAnalStateComplete; |
| 3954 | } | 3967 | } |
| 3955 | | 3968 | |
| 3956 | static void analyze_fn_body(CodeGen *g, ZigFn *fn_table_entry) { | 3969 | static void analyze_fn_body(CodeGen *g, ZigFn *fn_table_entry) { |