fix false positive error with same named methods in incomplete struct

This commit is contained in:
Andrew Kelley
2016-02-02 20:06:51 -07:00
parent d3de73739f
commit a50474e7cf
2 changed files with 43 additions and 6 deletions

View File

@@ -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");
}