authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2019-10-05 14:09:09-04:00
committergravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2019-10-05 14:09:09-04:00
loga23a022820d24f660b314457e1984ceb2586e109
tree5de4e8092445464ef9fe23ecac3af2cc6f94dbd0
parenta7c9aa7ddb06fe14c4c67e317586177141c9e37a
signaturelock-open Commit is signed but in an unrecognized format.

fix container member access for fn/struct-fn

- 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 #3367

3 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 @@
1const std = @import("std");
2const expect = std.testing.expect;
3
4const Foo = struct {
5 usingnamespace Mixin;
6};
7
8const Mixin = struct {
9 pub fn two(self: Foo) void {}
10};
11
12test "container member access usingnamespace decls" {
13 var foo = Foo{};
14 foo.two();
15}