From a50474e7cfc97e404fbb9f3b2f33507afac0ae2b Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 2 Feb 2016 20:06:51 -0700 Subject: fix false positive error with same named methods in incomplete struct --- test/run_tests.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'test/run_tests.cpp') diff --git a/test/run_tests.cpp b/test/run_tests.cpp index b8cc6fc210..dd5f085276 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -1549,6 +1549,35 @@ pub fn main(args: [][]u8) -> %void { } )SOURCE", "OK\n"); + + + add_simple_case("same named methods in incomplete struct", R"SOURCE( +import "std.zig"; + +struct Foo { + field1: Bar, + + fn method(a: &Foo) -> bool { true } +} + +struct Bar { + field2: i32, + + fn method(b: &Bar) -> bool { true } +} + +pub fn main(args: [][]u8) -> %void { + const bar = Bar {.field2 = 13,}; + const foo = Foo {.field1 = bar,}; + if (!foo.method()) { + %%stdout.printf("BAD\n"); + } + if (!bar.method()) { + %%stdout.printf("BAD\n"); + } + %%stdout.printf("OK\n"); +} + )SOURCE", "OK\n"); } -- cgit v1.2.3