mirror of
https://github.com/ziglang/zig.git
synced 2025-12-25 15:43:06 +00:00
add a test for returning a type that closes over a local const
closes #552
This commit is contained in:
parent
bb39e503c0
commit
e7c04b6df2
@ -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);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user