Stream: beginners

Topic: Add test to validate allocation counts?


view this post on Zulip Eric Rogstad (Jul 13 2026 at 07:52):

Hey @Richard Feldman, I saw that your PR #10064 went in yesterday. Were you aware that it fixed an issue that had been introduced in your PR #9848, which caused all for loops to make N+1 heap allocations?

I came across this bug yesterday when working on JSON parsing (see: #beginners > Attempted JSON string parsing fix), and used Claude to help me track down the source of the bug and draft a fix, only to rebase on main and see that you'd already made the fix. (The fix was to delete a check in solved_lir_lower.zig that boxed any opaque nominal whose backing record contains a callable, which had resulted in every for-loop iterator getting heap-boxed and rebuilt on each step.)

As part of my investigation I had built a test that repros the bug and verifies the fix, and it seemed like it could be useful to have a generic ability to test for an unexpected number of allocations. So here's a PR that adds the test: #10127.

What do you think?

view this post on Zulip Richard Feldman (Jul 13 2026 at 12:08):

yeah I saw that! I definitely like the idea - I'll review that PR when I get a chance! :raised_hands:


Last updated: Jul 23 2026 at 13:15 UTC