Stream: contributing

Topic: Request For Assistance - Snapshots


view this post on Zulip Luke Boswell (Jul 02 2025 at 05:26):

Just wanted to make a post in case anyone is interested in helping out with the new compiler and looking for ideas that don't require any Zig or Rust experience -- just pure Roc.

We have golden snapshots in src/snapshots that we use to validate the behaviour of the zig compiler. They take source code, from simple isolated expressions and statements, all the way up to multi-file apps, packages and platforms.

The snapshot tool processes the snapshot files through each compiler stage; Source -> Tokenize -> Parse -> Canonicalize -> Type Check -> (in future) later stages -- and generates a new markdown section with human readable representation for that stage. This helps identify bugs and partially implemented features, and mitigates against any regressions as we build.

If you are interested in helping out please don't hesitate to make a draft PR or ask any questions. The more snapshots we have of realistic Roc code the more confidence we have that our implementation has covered the various edge cases, and also significantly improves the seed inputs for our fuzzers to surface bugs deeper in our compiler.

I just recently added a package in src/snapshots/plume_package as an example if you wanted to check that out. I converted my roc plume package which provides an API wrapper around plotly.js. It currently only has a couple of files, but I'd like to expand that to more of the package. Who knows, I may even just copy-paste it back into my package when the new compiler lands and my migration is already complete :wink:

I needed to convert it from the current roc syntax to our new 0.1 design -- so I went through and made changes for that, however the syntax is very similar. The biggest changes is probably the change from using whitespace for blocks to using braces, and spaces in types to using parens and commas.

I missed a few things while converting the syntax over, but running zig build snapshot and looking at the Problems that are generated, I was able to iterate quickly on any issues I'd missed.

There are also many other example snapshots for inspiration on what is valid Roc 0.1 syntax -- or at least currently supported.

view this post on Zulip Kevin Hovsäter (Jul 03 2025 at 08:13):

I built a parser combinator library for a Roc talk I gave earlier this year but had to rewrite in Elm due to a compiler bug. See #beginners > Why is my parser causing a stack overflow? @ 💬 for details.

Would it make sense to add the code as a snapshot?

view this post on Zulip Luke Boswell (Jul 03 2025 at 08:14):

Yeah for sure -- if you need any help with the new syntax lmk

view this post on Zulip Kevin Hovsäter (Jul 03 2025 at 08:17):

I'll give it a shot tonight. I guess there's no way (as of yet) to know if the conversion is correct or not other than having someone look it over? I'll send you the PR once I have a draft ready. :slight_smile:

view this post on Zulip Luke Boswell (Jul 03 2025 at 08:20):

If you add it as a snapshot, then run zig build snapshot (we're using zig version 14) it will generate all the other sections and you can see if there are any parsing problems etc.

view this post on Zulip Luke Boswell (Jul 03 2025 at 08:21):

I'm very interested in how you find the setup, it's a new thing we've put together to help develop the new compiler.

view this post on Zulip Kevin Hovsäter (Jul 03 2025 at 08:27):

That seems really nice. I'll report back once I get off work. :slight_smile:


Last updated: Jul 06 2025 at 12:14 UTC