diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-02-02 20:06:51 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-02-02 20:06:51 -0700 |
| commit | a50474e7cfc97e404fbb9f3b2f33507afac0ae2b (patch) | |
| tree | 98af3b194f0db5878febb2a88fcfe952bb0cc356 /test/run_tests.cpp | |
| parent | d3de73739f88daa05cc7a93f12c262b27a987182 (diff) | |
| download | zig-a50474e7cfc97e404fbb9f3b2f33507afac0ae2b.tar.gz zig-a50474e7cfc97e404fbb9f3b2f33507afac0ae2b.zip | |
fix false positive error with same named methods in incomplete struct
Diffstat (limited to 'test/run_tests.cpp')
| -rw-r--r-- | test/run_tests.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
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"); } |
