| author | |
| committer | |
| log | eaa6b04c3cb8073d5a1510560ec8f1e433984895 |
| tree | 4e65cd3c8cb3d37b7037a8c92b65ca4b752113eb |
| parent | 0f820d0bdf98b3f8429a9cf2f1b405c2c0a4d958 |
2 files changed, 25 insertions(+), 0 deletions(-)
src/Sema.zig+2| ... | @@ -4967,6 +4967,8 @@ fn lookupInNamespace( | ... | @@ -4967,6 +4967,8 @@ fn lookupInNamespace( |
| 4967 | var it = check_ns.usingnamespace_set.iterator(); | 4967 | var it = check_ns.usingnamespace_set.iterator(); |
| 4968 | while (it.next()) |entry| { | 4968 | while (it.next()) |entry| { |
| 4969 | const sub_usingnamespace_decl_index = entry.key_ptr.*; | 4969 | const sub_usingnamespace_decl_index = entry.key_ptr.*; |
| 4970 | // Skip the decl we're currently analysing. | ||
| 4971 | if (sub_usingnamespace_decl_index == sema.owner_decl_index) continue; | ||
| 4970 | const sub_usingnamespace_decl = mod.declPtr(sub_usingnamespace_decl_index); | 4972 | const sub_usingnamespace_decl = mod.declPtr(sub_usingnamespace_decl_index); |
| 4971 | const sub_is_pub = entry.value_ptr.*; | 4973 | const sub_is_pub = entry.value_ptr.*; |
| 4972 | if (!sub_is_pub and src_file != sub_usingnamespace_decl.getFileScope()) { | 4974 | if (!sub_is_pub and src_file != sub_usingnamespace_decl.getFileScope()) { |
test/behavior/basic.zig+23| ... | @@ -1086,3 +1086,26 @@ test "inline call of function with a switch inside the return statement" { | ... | @@ -1086,3 +1086,26 @@ test "inline call of function with a switch inside the return statement" { |
| 1086 | }; | 1086 | }; |
| 1087 | try expect(S.foo(1) == 1); | 1087 | try expect(S.foo(1) == 1); |
| 1088 | } | 1088 | } |
| 1089 | |||
| 1090 | test "namespace lookup ignores decl causing the lookup" { | ||
| 1091 | if (builtin.zig_backend == .stage1) return error.SkipZigTest; | ||
| 1092 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO | ||
| 1093 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO | ||
| 1094 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
| 1095 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
| 1096 | |||
| 1097 | const S = struct { | ||
| 1098 | fn Mixin(comptime T: type) type { | ||
| 1099 | return struct { | ||
| 1100 | fn foo() void { | ||
| 1101 | const set = std.EnumSet(T.E).init(undefined); | ||
| 1102 | _ = set; | ||
| 1103 | } | ||
| 1104 | }; | ||
| 1105 | } | ||
| 1106 | |||
| 1107 | const E = enum { a, b }; | ||
| 1108 | usingnamespace Mixin(@This()); | ||
| 1109 | }; | ||
| 1110 | _ = S.foo(); | ||
| 1111 | } |