| ... | @@ -59,6 +59,7 @@ ErrorMsg *add_token_error(CodeGen *g, ZigType *owner, Token *token, Buf *msg) { | ... | @@ -59,6 +59,7 @@ ErrorMsg *add_token_error(CodeGen *g, ZigType *owner, Token *token, Buf *msg) { |
| 59 | root_struct->source_code, root_struct->line_offsets, msg); | 59 | root_struct->source_code, root_struct->line_offsets, msg); |
| 60 | | 60 | |
| 61 | g->errors.append(err); | 61 | g->errors.append(err); |
| | 62 | g->trace_err = err; |
| 62 | return err; | 63 | return err; |
| 63 | } | 64 | } |
| 64 | | 65 | |
| ... | @@ -1793,7 +1794,7 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type) { | ... | @@ -1793,7 +1794,7 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type) { |
| 1793 | if (struct_type->data.structure.resolve_loop_flag_other) { | 1794 | if (struct_type->data.structure.resolve_loop_flag_other) { |
| 1794 | if (struct_type->data.structure.resolve_status != ResolveStatusInvalid) { | 1795 | if (struct_type->data.structure.resolve_status != ResolveStatusInvalid) { |
| 1795 | struct_type->data.structure.resolve_status = ResolveStatusInvalid; | 1796 | struct_type->data.structure.resolve_status = ResolveStatusInvalid; |
| 1796 | g->trace_err = add_node_error(g, decl_node, | 1797 | add_node_error(g, decl_node, |
| 1797 | buf_sprintf("struct '%s' depends on its own size", buf_ptr(&struct_type->name))); | 1798 | buf_sprintf("struct '%s' depends on its own size", buf_ptr(&struct_type->name))); |
| 1798 | } | 1799 | } |
| 1799 | return ErrorSemanticAnalyzeFail; | 1800 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -1947,7 +1948,7 @@ static Error resolve_union_alignment(CodeGen *g, ZigType *union_type) { | ... | @@ -1947,7 +1948,7 @@ static Error resolve_union_alignment(CodeGen *g, ZigType *union_type) { |
| 1947 | if (union_type->data.unionation.resolve_loop_flag_other) { | 1948 | if (union_type->data.unionation.resolve_loop_flag_other) { |
| 1948 | if (union_type->data.unionation.resolve_status != ResolveStatusInvalid) { | 1949 | if (union_type->data.unionation.resolve_status != ResolveStatusInvalid) { |
| 1949 | union_type->data.unionation.resolve_status = ResolveStatusInvalid; | 1950 | union_type->data.unionation.resolve_status = ResolveStatusInvalid; |
| 1950 | g->trace_err = add_node_error(g, decl_node, | 1951 | add_node_error(g, decl_node, |
| 1951 | buf_sprintf("union '%s' depends on its own alignment", buf_ptr(&union_type->name))); | 1952 | buf_sprintf("union '%s' depends on its own alignment", buf_ptr(&union_type->name))); |
| 1952 | } | 1953 | } |
| 1953 | return ErrorSemanticAnalyzeFail; | 1954 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -2058,7 +2059,7 @@ static Error resolve_union_type(CodeGen *g, ZigType *union_type) { | ... | @@ -2058,7 +2059,7 @@ static Error resolve_union_type(CodeGen *g, ZigType *union_type) { |
| 2058 | if (union_type->data.unionation.resolve_loop_flag_other) { | 2059 | if (union_type->data.unionation.resolve_loop_flag_other) { |
| 2059 | if (union_type->data.unionation.resolve_status != ResolveStatusInvalid) { | 2060 | if (union_type->data.unionation.resolve_status != ResolveStatusInvalid) { |
| 2060 | union_type->data.unionation.resolve_status = ResolveStatusInvalid; | 2061 | union_type->data.unionation.resolve_status = ResolveStatusInvalid; |
| 2061 | g->trace_err = add_node_error(g, decl_node, | 2062 | add_node_error(g, decl_node, |
| 2062 | buf_sprintf("union '%s' depends on its own size", buf_ptr(&union_type->name))); | 2063 | buf_sprintf("union '%s' depends on its own size", buf_ptr(&union_type->name))); |
| 2063 | } | 2064 | } |
| 2064 | return ErrorSemanticAnalyzeFail; | 2065 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -2160,7 +2161,7 @@ static Error resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type) { | ... | @@ -2160,7 +2161,7 @@ static Error resolve_enum_zero_bits(CodeGen *g, ZigType *enum_type) { |
| 2160 | if (enum_type->data.enumeration.resolve_loop_flag) { | 2161 | if (enum_type->data.enumeration.resolve_loop_flag) { |
| 2161 | if (enum_type->data.enumeration.resolve_status != ResolveStatusInvalid) { | 2162 | if (enum_type->data.enumeration.resolve_status != ResolveStatusInvalid) { |
| 2162 | enum_type->data.enumeration.resolve_status = ResolveStatusInvalid; | 2163 | enum_type->data.enumeration.resolve_status = ResolveStatusInvalid; |
| 2163 | g->trace_err = add_node_error(g, decl_node, | 2164 | add_node_error(g, decl_node, |
| 2164 | buf_sprintf("enum '%s' depends on itself", | 2165 | buf_sprintf("enum '%s' depends on itself", |
| 2165 | buf_ptr(&enum_type->name))); | 2166 | buf_ptr(&enum_type->name))); |
| 2166 | } | 2167 | } |
| ... | @@ -2337,7 +2338,7 @@ static Error resolve_struct_zero_bits(CodeGen *g, ZigType *struct_type) { | ... | @@ -2337,7 +2338,7 @@ static Error resolve_struct_zero_bits(CodeGen *g, ZigType *struct_type) { |
| 2337 | if (struct_type->data.structure.resolve_loop_flag_zero_bits) { | 2338 | if (struct_type->data.structure.resolve_loop_flag_zero_bits) { |
| 2338 | if (struct_type->data.structure.resolve_status != ResolveStatusInvalid) { | 2339 | if (struct_type->data.structure.resolve_status != ResolveStatusInvalid) { |
| 2339 | struct_type->data.structure.resolve_status = ResolveStatusInvalid; | 2340 | struct_type->data.structure.resolve_status = ResolveStatusInvalid; |
| 2340 | g->trace_err = add_node_error(g, decl_node, | 2341 | add_node_error(g, decl_node, |
| 2341 | buf_sprintf("struct '%s' depends on itself", | 2342 | buf_sprintf("struct '%s' depends on itself", |
| 2342 | buf_ptr(&struct_type->name))); | 2343 | buf_ptr(&struct_type->name))); |
| 2343 | } | 2344 | } |
| ... | @@ -2462,7 +2463,7 @@ static Error resolve_struct_alignment(CodeGen *g, ZigType *struct_type) { | ... | @@ -2462,7 +2463,7 @@ static Error resolve_struct_alignment(CodeGen *g, ZigType *struct_type) { |
| 2462 | if (struct_type->data.structure.resolve_loop_flag_other) { | 2463 | if (struct_type->data.structure.resolve_loop_flag_other) { |
| 2463 | if (struct_type->data.structure.resolve_status != ResolveStatusInvalid) { | 2464 | if (struct_type->data.structure.resolve_status != ResolveStatusInvalid) { |
| 2464 | struct_type->data.structure.resolve_status = ResolveStatusInvalid; | 2465 | struct_type->data.structure.resolve_status = ResolveStatusInvalid; |
| 2465 | g->trace_err = add_node_error(g, decl_node, | 2466 | add_node_error(g, decl_node, |
| 2466 | buf_sprintf("struct '%s' depends on its own alignment", buf_ptr(&struct_type->name))); | 2467 | buf_sprintf("struct '%s' depends on its own alignment", buf_ptr(&struct_type->name))); |
| 2467 | } | 2468 | } |
| 2468 | return ErrorSemanticAnalyzeFail; | 2469 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -2530,7 +2531,7 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) { | ... | @@ -2530,7 +2531,7 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) { |
| 2530 | if (union_type->data.unionation.resolve_loop_flag_zero_bits) { | 2531 | if (union_type->data.unionation.resolve_loop_flag_zero_bits) { |
| 2531 | if (union_type->data.unionation.resolve_status != ResolveStatusInvalid) { | 2532 | if (union_type->data.unionation.resolve_status != ResolveStatusInvalid) { |
| 2532 | union_type->data.unionation.resolve_status = ResolveStatusInvalid; | 2533 | union_type->data.unionation.resolve_status = ResolveStatusInvalid; |
| 2533 | g->trace_err = add_node_error(g, decl_node, | 2534 | add_node_error(g, decl_node, |
| 2534 | buf_sprintf("union '%s' depends on itself", | 2535 | buf_sprintf("union '%s' depends on itself", |
| 2535 | buf_ptr(&union_type->name))); | 2536 | buf_ptr(&union_type->name))); |
| 2536 | } | 2537 | } |
| ... | @@ -3423,7 +3424,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) { | ... | @@ -3423,7 +3424,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) { |
| 3423 | ZigType *explicit_type = nullptr; | 3424 | ZigType *explicit_type = nullptr; |
| 3424 | if (var_decl->type) { | 3425 | if (var_decl->type) { |
| 3425 | if (tld_var->analyzing_type) { | 3426 | if (tld_var->analyzing_type) { |
| 3426 | g->trace_err = add_node_error(g, var_decl->type, | 3427 | add_node_error(g, var_decl->type, |
| 3427 | buf_sprintf("type of '%s' depends on itself", buf_ptr(tld_var->base.name))); | 3428 | buf_sprintf("type of '%s' depends on itself", buf_ptr(tld_var->base.name))); |
| 3428 | explicit_type = g->builtin_types.entry_invalid; | 3429 | explicit_type = g->builtin_types.entry_invalid; |
| 3429 | } else { | 3430 | } else { |
| ... | @@ -4001,6 +4002,13 @@ static void resolve_async_fn_frame(CodeGen *g, ZigFn *fn) { | ... | @@ -4001,6 +4002,13 @@ static void resolve_async_fn_frame(CodeGen *g, ZigFn *fn) { |
| 4001 | ZigType *frame_type = get_fn_frame_type(g, fn); | 4002 | ZigType *frame_type = get_fn_frame_type(g, fn); |
| 4002 | Error err; | 4003 | Error err; |
| 4003 | if ((err = type_resolve(g, frame_type, ResolveStatusSizeKnown))) { | 4004 | if ((err = type_resolve(g, frame_type, ResolveStatusSizeKnown))) { |
| | 4005 | if (g->trace_err != nullptr && frame_type->data.frame.resolve_loop_src_node != nullptr && |
| | 4006 | !frame_type->data.frame.reported_loop_err) |
| | 4007 | { |
| | 4008 | frame_type->data.frame.reported_loop_err = true; |
| | 4009 | g->trace_err = add_error_note(g, g->trace_err, frame_type->data.frame.resolve_loop_src_node, |
| | 4010 | buf_sprintf("when analyzing type '%s' here", buf_ptr(&frame_type->name))); |
| | 4011 | } |
| 4004 | fn->anal_state = FnAnalStateInvalid; | 4012 | fn->anal_state = FnAnalStateInvalid; |
| 4005 | return; | 4013 | return; |
| 4006 | } | 4014 | } |
| ... | @@ -5406,8 +5414,7 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) { | ... | @@ -5406,8 +5414,7 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) { |
| 5406 | | 5414 | |
| 5407 | if (frame_type->data.frame.resolve_loop_type != nullptr) { | 5415 | if (frame_type->data.frame.resolve_loop_type != nullptr) { |
| 5408 | if (!frame_type->data.frame.reported_loop_err) { | 5416 | if (!frame_type->data.frame.reported_loop_err) { |
| 5409 | frame_type->data.frame.reported_loop_err = true; | 5417 | add_node_error(g, fn->proto_node, |
| 5410 | g->trace_err = add_node_error(g, fn->proto_node, | | |
| 5411 | buf_sprintf("'%s' depends on itself", buf_ptr(&frame_type->name))); | 5418 | buf_sprintf("'%s' depends on itself", buf_ptr(&frame_type->name))); |
| 5412 | } | 5419 | } |
| 5413 | return ErrorSemanticAnalyzeFail; | 5420 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -5424,7 +5431,7 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) { | ... | @@ -5424,7 +5431,7 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) { |
| 5424 | return ErrorSemanticAnalyzeFail; | 5431 | return ErrorSemanticAnalyzeFail; |
| 5425 | break; | 5432 | break; |
| 5426 | case FnAnalStateProbing: { | 5433 | case FnAnalStateProbing: { |
| 5427 | g->trace_err = add_node_error(g, fn->proto_node, | 5434 | add_node_error(g, fn->proto_node, |
| 5428 | buf_sprintf("cannot resolve '%s': function not fully analyzed yet", | 5435 | buf_sprintf("cannot resolve '%s': function not fully analyzed yet", |
| 5429 | buf_ptr(&frame_type->name))); | 5436 | buf_ptr(&frame_type->name))); |
| 5430 | return ErrorSemanticAnalyzeFail; | 5437 | return ErrorSemanticAnalyzeFail; |