diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-05-20 23:13:02 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-05-20 23:13:02 -0400 |
| commit | 140dc2f43e347ddddc2f6f344b388bdc74c97c56 (patch) | |
| tree | 56d3443400f4f2a11c975607d1146127a62575ca /src/ir.cpp | |
| parent | 688aa114e434e05b96f916c168f177aa0484baec (diff) | |
| download | zig-140dc2f43e347ddddc2f6f344b388bdc74c97c56.tar.gz zig-140dc2f43e347ddddc2f6f344b388bdc74c97c56.zip | |
stage1: fix false positive redeclared variable compile error
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 20e83ecb9d..cb0b6223c7 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -5300,9 +5300,18 @@ static ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_s } else { Tld *tld = find_decl(codegen, parent_scope, name); if (tld != nullptr) { - ErrorMsg *msg = add_node_error(codegen, node, - buf_sprintf("redefinition of '%s'", buf_ptr(name))); - add_error_note(codegen, msg, tld->source_node, buf_sprintf("previous definition is here")); + bool want_err_msg = true; + if (tld->id == TldIdVar) { + ZigVar *var = reinterpret_cast<TldVar *>(tld)->var; + if (var->var_type != nullptr && type_is_invalid(var->var_type)) { + want_err_msg = false; + } + } + if (want_err_msg) { + ErrorMsg *msg = add_node_error(codegen, node, + buf_sprintf("redefinition of '%s'", buf_ptr(name))); + add_error_note(codegen, msg, tld->source_node, buf_sprintf("previous definition is here")); + } variable_entry->var_type = codegen->builtin_types.entry_invalid; } } |
