| author | |
| committer | |
| log | a23a022820d24f660b314457e1984ceb2586e109 |
| tree | 5de4e8092445464ef9fe23ecac3af2cc6f94dbd0 |
| parent | a7c9aa7ddb06fe14c4c67e317586177141c9e37a |
| signature |
- decls brought in via `usingnamespace` were not always found
because lookup was performed directly against decl_table and
use_decls was never consulted
- fix to use find_container_decl() path instead
- closes #33673 files changed, 17 insertions(+), 2 deletions(-)
src/ir.cpp+1-2| ... | @@ -17673,8 +17673,7 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, | ... | @@ -17673,8 +17673,7 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 17673 | if (!is_slice(bare_struct_type)) { | 17673 | if (!is_slice(bare_struct_type)) { |
| 17674 | ScopeDecls *container_scope = get_container_scope(bare_struct_type); | 17674 | ScopeDecls *container_scope = get_container_scope(bare_struct_type); |
| 17675 | assert(container_scope != nullptr); | 17675 | assert(container_scope != nullptr); |
| 17676 | auto entry = container_scope->decl_table.maybe_get(field_name); | 17676 | auto tld = find_container_decl(ira->codegen, container_scope, field_name); |
| 17677 | Tld *tld = entry ? entry->value : nullptr; | ||
| 17678 | if (tld) { | 17677 | if (tld) { |
| 17679 | if (tld->id == TldIdFn) { | 17678 | if (tld->id == TldIdFn) { |
| 17680 | resolve_top_level_decl(ira->codegen, tld, source_instr->source_node, false); | 17679 | resolve_top_level_decl(ira->codegen, tld, source_instr->source_node, false); |
test/stage1/behavior.zig+1| ... | @@ -34,6 +34,7 @@ comptime { | ... | @@ -34,6 +34,7 @@ comptime { |
| 34 | _ = @import("behavior/bugs/2692.zig"); | 34 | _ = @import("behavior/bugs/2692.zig"); |
| 35 | _ = @import("behavior/bugs/3046.zig"); | 35 | _ = @import("behavior/bugs/3046.zig"); |
| 36 | _ = @import("behavior/bugs/3112.zig"); | 36 | _ = @import("behavior/bugs/3112.zig"); |
| 37 | _ = @import("behavior/bugs/3367.zig"); | ||
| 37 | _ = @import("behavior/bugs/394.zig"); | 38 | _ = @import("behavior/bugs/394.zig"); |
| 38 | _ = @import("behavior/bugs/421.zig"); | 39 | _ = @import("behavior/bugs/421.zig"); |
| 39 | _ = @import("behavior/bugs/529.zig"); | 40 | _ = @import("behavior/bugs/529.zig"); |
test/stage1/behavior/bugs/3367.zig created+15| ... | @@ -0,0 +1,15 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const expect = std.testing.expect; | ||
| 3 | |||
| 4 | const Foo = struct { | ||
| 5 | usingnamespace Mixin; | ||
| 6 | }; | ||
| 7 | |||
| 8 | const Mixin = struct { | ||
| 9 | pub fn two(self: Foo) void {} | ||
| 10 | }; | ||
| 11 | |||
| 12 | test "container member access usingnamespace decls" { | ||
| 13 | var foo = Foo{}; | ||
| 14 | foo.two(); | ||
| 15 | } | ||