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,
1767317673 if (!is_slice(bare_struct_type)) {
1767417674 ScopeDecls *container_scope = get_container_scope(bare_struct_type);
1767517675 assert(container_scope != nullptr);
17676 auto entry = container_scope->decl_table.maybe_get(field_name);
17677 Tld *tld = entry ? entry->value : nullptr;
17676 auto tld = find_container_decl(ira->codegen, container_scope, field_name);
1767817677 if (tld) {
1767917678 if (tld->id == TldIdFn) {
1768017679 resolve_top_level_decl(ira->codegen, tld, source_instr->source_node, false);
test/stage1/behavior.zig+1
......@@ -34,6 +34,7 @@ comptime {
3434 _ = @import("behavior/bugs/2692.zig");
3535 _ = @import("behavior/bugs/3046.zig");
3636 _ = @import("behavior/bugs/3112.zig");
37 _ = @import("behavior/bugs/3367.zig");
3738 _ = @import("behavior/bugs/394.zig");
3839 _ = @import("behavior/bugs/421.zig");
3940 _ = @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}