| author | |
| committer | |
| log | 2c8864f634cbb42bf45f4f6b7109e9129b357247 |
| tree | ba98972c0178252fdb8f5790bc17606f834c37c2 |
| parent | b89a09af4bb0064bb3d37acef4c9c1d4ee1515a6 |
Closes #33162 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 | 3676 | } |
| 3677 | 3677 | if (search_scope != nullptr) { |
| 3678 | 3678 | Tld *tld = find_decl(g, search_scope, name); |
| 3679 | if (tld != nullptr) { | |
| 3679 | if (tld != nullptr && tld != src_tld) { | |
| 3680 | 3680 | ErrorMsg *msg = add_node_error(g, source_node, |
| 3681 | 3681 | buf_sprintf("redefinition of '%s'", buf_ptr(name))); |
| 3682 | 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 | 12 | std2.testing.expect(true); |
| 13 | 13 | testing2.expect(true); |
| 14 | 14 | } |
| 15 | ||
| 16 | usingnamespace struct { | |
| 17 | pub const foo = 42; | |
| 18 | }; | |
| 19 | ||
| 20 | test "usingnamespace does not redeclare an imported variable" { | |
| 21 | comptime std.testing.expect(foo == 42); | |
| 22 | } |