Commit e7c04b6df2

Andrew Kelley <superjoe30@gmail.com>
2018-01-07 06:50:43
add a test for returning a type that closes over a local const
closes #552
1 parent bb39e50
Changed files (1)
test
cases
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);
+}