# stage2: fix small memory leak of test_functions when using \`zig test\` · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/e494ce760428cde79b63e9a9016c4af06484eef3)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: e494ce760428cde79b63e9a9016c4af06484eef3

Requested commit: e494ce760428cde79b63e9a9016c4af06484eef3

Commit: e494ce760428cde79b63e9a9016c4af06484eef3

Tree: 3205a2de5e327e61883c1d2dec37e027fe079842

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage2: fix small memory leak of test_functions when using `zig test`

The way `zig test` works is that it uses a stand-in

var test_functions: []const TestFn = undefined;

during semantic analysis, but then just before codegen, it swaps out the
value with a constant like this:

const test_functions: []const TestFn = .{foo, bar, baz, etc};

Before this commit, the `Module.Variable` associated with the stand-in
value was leaked; now it is properly cleaned up before being replaced.

```

## Parents

- [c1a5ff34f3f68a2a0bc32828ab483328cd436fea](https://git.cafe/gitcafe/zig/commit/c1a5ff34f3f68a2a0bc32828ab483328cd436fea?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/e494ce760428cde79b63e9a9016c4af06484eef3?format=markdown)
