From 8058b5e0a92e4eac05ba19aabed1fc041353c69b Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 2 Feb 2016 19:09:53 -0700 Subject: fix crash when incomplete struct used as argument closes #107 --- test/run_tests.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test/run_tests.cpp') diff --git a/test/run_tests.cpp b/test/run_tests.cpp index 39bbf504b8..946f55f9fd 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -1513,6 +1513,42 @@ pub fn main(args: [][]u8) -> %void { %%stdout.printf("OK\n"); } )SOURCE", "OK\n"); + + + add_simple_case("incomplete struct parameter top level decl", R"SOURCE( +import "std.zig"; +struct A { + b: B, +} + +struct B { + c: C, +} + +struct C { + x: i32, + + fn d(c: C) { + %%stdout.printf("OK\n"); + } +} + +fn foo(a: A) { + a.b.c.d(); +} + +pub fn main(args: [][]u8) -> %void { + const a = A { + .b = B { + .c = C { + .x = 13, + }, + }, + }; + foo(a); +} + + )SOURCE", "OK\n"); } -- cgit v1.2.3