authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-01-07 00:50:43-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-01-07 00:50:43-05:00
loge7c04b6df2d839a25cc4e2cf8da900c7dd04bc7d
tree1873a03a606bfc066c4da9b90a908b357dcbcbd3
parentbb39e503c0179b18c4e440bae021e786c70deb06

add a test for returning a type that closes over a local const

closes #552

1 files changed, 12 insertions(+), 0 deletions(-)

test/cases/misc.zig+12
......@@ -596,3 +596,15 @@ fn testStructInFn() {
596596
597597 assert(block.kind == 1235);
598598}
599
600fn fnThatClosesOverLocalConst() -> type {
601 const c = 1;
602 return struct {
603 fn g() -> i32 { return c; }
604 };
605}
606
607test "function closes over local const" {
608 const x = fnThatClosesOverLocalConst().g();
609 assert(x == 1);
610}