aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/cases/misc.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/cases/misc.zig b/test/cases/misc.zig
index b6ec6e63cc..e3ddfdfd76 100644
--- 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);
+}