diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/behavior/basic.zig | 21 | ||||
| -rw-r--r-- | test/cases/compile_errors/decl_shadows_local.zig | 22 |
2 files changed, 43 insertions, 0 deletions
diff --git a/test/behavior/basic.zig b/test/behavior/basic.zig index 1a1412420a..4d8b176fbf 100644 --- a/test/behavior/basic.zig +++ b/test/behavior/basic.zig @@ -1104,3 +1104,24 @@ test "namespace lookup ignores decl causing the lookup" { }; _ = S.foo(); } + +test "ambiguous reference error ignores current declaration" { + const S = struct { + const foo = 666; + + const a = @This(); + const b = struct { + const foo = a.foo; + const bar = struct { + bar: u32 = b.foo, + }; + + comptime { + _ = b.foo; + } + }; + + usingnamespace b; + }; + try expect(S.b.foo == 666); +} diff --git a/test/cases/compile_errors/decl_shadows_local.zig b/test/cases/compile_errors/decl_shadows_local.zig new file mode 100644 index 0000000000..cb48cafa45 --- /dev/null +++ b/test/cases/compile_errors/decl_shadows_local.zig @@ -0,0 +1,22 @@ +fn foo(a: usize) void { + struct { + const a = 1; + }; +} +fn bar(a: usize) void { + struct { + const b = struct { + const a = 1; + }; + }; + _ = a; +} + +// error +// backend=stage2 +// target=native +// +// :3:15: error: redeclaration of function parameter 'a' +// :1:8: note: previous declaration here +// :9:19: error: redeclaration of function parameter 'a' +// :6:8: note: previous declaration here |
