commit e7c04b6df2d839a25cc4e2cf8da900c7dd04bc7d (tree) parent bb39e503c0179b18c4e440bae021e786c70deb06 Author: Andrew Kelley <superjoe30@gmail.com> Date: Sun, 7 Jan 2018 00:50:43 -0500 add a test for returning a type that closes over a local const closes #552 Diffstat:
| M | test/cases/misc.zig | | | 12 | ++++++++++++ |
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git a/test/cases/misc.zig b/test/cases/misc.zig @@ -596,3 +596,15 @@ fn testStructInFn() { assert(block.kind == 1235); } + +fn fnThatClosesOverLocalConst() -> type { + const c = 1; + return struct { + fn g() -> i32 { return c; } + }; +} + +test "function closes over local const" { + const x = fnThatClosesOverLocalConst().g(); + assert(x == 1); +}