authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-09-26 17:54:45+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-26 13:39:09-04:00
log2c8864f634cbb42bf45f4f6b7109e9129b357247
treeba98972c0178252fdb8f5790bc17606f834c37c2
parentb89a09af4bb0064bb3d37acef4c9c1d4ee1515a6

Don't warn about redeclaration for the same var node

Closes #3316

2 files changed, 9 insertions(+), 1 deletions(-)

src/analyze.cpp+1-1
...@@ -3676,7 +3676,7 @@ ZigVar *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf...@@ -3676,7 +3676,7 @@ ZigVar *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf
3676 }3676 }
3677 if (search_scope != nullptr) {3677 if (search_scope != nullptr) {
3678 Tld *tld = find_decl(g, search_scope, name);3678 Tld *tld = find_decl(g, search_scope, name);
3679 if (tld != nullptr) {3679 if (tld != nullptr && tld != src_tld) {
3680 ErrorMsg *msg = add_node_error(g, source_node,3680 ErrorMsg *msg = add_node_error(g, source_node,
3681 buf_sprintf("redefinition of '%s'", buf_ptr(name)));3681 buf_sprintf("redefinition of '%s'", buf_ptr(name)));
3682 add_error_note(g, msg, tld->source_node, buf_sprintf("previous definition is here"));3682 add_error_note(g, msg, tld->source_node, buf_sprintf("previous definition is here"));
test/stage1/behavior/usingnamespace.zig+8
...@@ -12,3 +12,11 @@ test "usingnamespace inside a generic struct" {...@@ -12,3 +12,11 @@ test "usingnamespace inside a generic struct" {
12 std2.testing.expect(true);12 std2.testing.expect(true);
13 testing2.expect(true);13 testing2.expect(true);
14}14}
15
16usingnamespace struct {
17 pub const foo = 42;
18};
19
20test "usingnamespace does not redeclare an imported variable" {
21 comptime std.testing.expect(foo == 42);
22}