| author | |
| committer | |
| log | e7c04b6df2d839a25cc4e2cf8da900c7dd04bc7d |
| tree | 1873a03a606bfc066c4da9b90a908b357dcbcbd3 |
| parent | bb39e503c0179b18c4e440bae021e786c70deb06 |
closes #5521 files changed, 12 insertions(+), 0 deletions(-)
test/cases/misc.zig+12| ... | ... | @@ -596,3 +596,15 @@ fn testStructInFn() { |
| 596 | 596 | |
| 597 | 597 | assert(block.kind == 1235); |
| 598 | 598 | } |
| 599 | ||
| 600 | fn fnThatClosesOverLocalConst() -> type { | |
| 601 | const c = 1; | |
| 602 | return struct { | |
| 603 | fn g() -> i32 { return c; } | |
| 604 | }; | |
| 605 | } | |
| 606 | ||
| 607 | test "function closes over local const" { | |
| 608 | const x = fnThatClosesOverLocalConst().g(); | |
| 609 | assert(x == 1); | |
| 610 | } |