zig/std/zig
Tyler Philbrick 16aee1f58a
Fix memory leak in parser tests
The `arena` instance being used bythe parse tree was valid and
pointed to valid memory, but existed as a local variable inside the
stack frame of the `parse` function (the `const arena`), which was never
stored anywhere before leaving the scope.

This meant that code above the `parse` function saw a valid instance of
an `ArenaAllocator` that pointed to the same backing memory, but didn't
posess any of the local state built up after the call to `parseRoot`,
basically the caller saw an empty arena.

This meant that when `deinit` was called, it saw an Arena with 0
allocations in it's `buffer_list` and wasn't able to destroy any of the
memory.  This caused it to leak and caused FailingAllocator to balk.

The fix is to make sure the parse tree is using the same instance of
ArenaAllocator as is reported up the call stack, the one inside the
`Tree{}` object.  I'm not sure why that field is marked with a comment
to remove it, as it's used by the `std.ast.Tree.deinit()` function, but
this change seems to solve the problem.
2019-05-12 01:54:30 -07:00
..
ast.zig
bench.zig
parse_string_literal.zig
parse.zig
parse2.zig
parser_test.zig
render.zig
tokenizer.zig