authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2019-10-05 15:47:07-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2019-10-05 15:47:07-04:00
loga82c6453c1553ce89ec24803d4192030639d79ab
tree22c39cef84328674b4f6a266d07d6e3edbff7246
parentedadccde549b99305882e795e44672a9f41be037
parenta23a022820d24f660b314457e1984ceb2586e109
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #3368 from mikdusan/issue.3367

fix: container member access `usingnamespace` decls fails

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}