Skip to content

Commit

Permalink
add a test for returning a type that closes over a local const
Browse files Browse the repository at this point in the history
closes #552
  • Loading branch information
andrewrk committed Jan 7, 2018
1 parent bb39e50 commit e7c04b6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/cases/misc.zig
Expand Up @@ -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);
}

0 comments on commit e7c04b6

Please sign in to comment.