| ... | ... | @@ -3612,6 +3612,12 @@ static void add_top_level_decl(CodeGen *g, ScopeDecls *decls_scope, Tld *tld) { |
| 3612 | 3612 | auto entry = decls_scope->decl_table.put_unique(tld->name, tld); |
| 3613 | 3613 | if (entry) { |
| 3614 | 3614 | Tld *other_tld = entry->value; |
| 3615 | if (other_tld->id == TldIdVar) { |
| 3616 | ZigVar *var = reinterpret_cast<TldVar *>(other_tld)->var; |
| 3617 | if (var->var_type != nullptr && type_is_invalid(var->var_type)) { |
| 3618 | return; // already reported compile error |
| 3619 | } |
| 3620 | } |
| 3615 | 3621 | ErrorMsg *msg = add_node_error(g, tld->source_node, buf_sprintf("redefinition of '%s'", buf_ptr(tld->name))); |
| 3616 | 3622 | add_error_note(g, msg, other_tld->source_node, buf_sprintf("previous definition is here")); |
| 3617 | 3623 | return; |
| ... | ... | @@ -3887,9 +3893,18 @@ ZigVar *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf |
| 3887 | 3893 | if (search_scope != nullptr) { |
| 3888 | 3894 | Tld *tld = find_decl(g, search_scope, name); |
| 3889 | 3895 | if (tld != nullptr && tld != src_tld) { |
| 3890 | | ErrorMsg *msg = add_node_error(g, source_node, |
| 3891 | | buf_sprintf("redefinition of '%s'", buf_ptr(name))); |
| 3892 | | add_error_note(g, msg, tld->source_node, buf_sprintf("previous definition is here")); |
| 3896 | bool want_err_msg = true; |
| 3897 | if (tld->id == TldIdVar) { |
| 3898 | ZigVar *var = reinterpret_cast<TldVar *>(tld)->var; |
| 3899 | if (var->var_type != nullptr && type_is_invalid(var->var_type)) { |
| 3900 | want_err_msg = false; |
| 3901 | } |
| 3902 | } |
| 3903 | if (want_err_msg) { |
| 3904 | ErrorMsg *msg = add_node_error(g, source_node, |
| 3905 | buf_sprintf("redefinition of '%s'", buf_ptr(name))); |
| 3906 | add_error_note(g, msg, tld->source_node, buf_sprintf("previous definition is here")); |
| 3907 | } |
| 3893 | 3908 | variable_entry->var_type = g->builtin_types.entry_invalid; |
| 3894 | 3909 | } |
| 3895 | 3910 | } |