Stream: ideas

Topic: converting snapshots from old compiler to new


view this post on Zulip Luke Boswell (Jun 14 2025 at 11:30):

I was wondering if there is anyone who is good at scripting and interested in bulk translating our snapshots from the rust compiler crates/compiler/test_syntax/tests/snapshots to the new format in src/snapshots/...?

There's a lot there so I imagine a script would be the way to go. No all of them will be valid with the new language design, but we can certainly delete any of those as we go.

It would be great to have these and really harden up the parser.

view this post on Zulip Anthony Bullard (Jun 15 2025 at 11:59):

It would be great if we could have the translater in the Rust version move them to v0.1 first and then run a script on that

view this post on Zulip Luke Boswell (Jun 27 2025 at 18:05):

@Norbert Hajagos would this interest you?

view this post on Zulip Luke Boswell (Jun 27 2025 at 18:06):

There will be some human review required. For example we dont have abilities in roc 0.1 syntax, so no need to worry about those tests etc.

view this post on Zulip Norbert Hajagos (Jun 27 2025 at 19:39):

I figure I would need to be working on the rust based formatter. I'm not familiar with that, but that just means I'll need more time. First thought was that it would be (sorry for the wording) "wasted learning", since we are abandoning that part of the code and rust with the new compiler soon. Then I realized that's how one misses on learning opportunities. The bigger the challenge :)

Am I correct, I should be looking at crates/compiler/fmt/src/migrate.rs ?
Are there tests for the "migrator" I could start from?
Going to bed, bye

view this post on Zulip Luke Boswell (Jun 27 2025 at 20:40):

I personally wouldn't bother with the migrate script or rust compiler, it's not strictly necessary and I'm not sure it would save much time.

You could write a bash or python script to copy them into the right folder with the snapshot format, then change the syntax by hand and delete any we dont want one by one. There is quite a few but it wouldn't take that long, and it's a good way to learn the new syntax. I've been doing a similar thing writing new snapshot tests to try and cover various combinations of features.

view this post on Zulip Luke Boswell (Jun 27 2025 at 20:53):

That being said I'm not that familiar with the translator we have in rust.

It may a simple as just using the roc binary and passing an argument like --migrate... in which case you might make a bash script to copy all the syntax tests into another format and make them .roc filles, and then convert them to snapshot format.

I haven't fully scoped out the task, it was just an idea to keep/re-use all the syntax tests.

view this post on Zulip Anthony Bullard (Jun 27 2025 at 21:23):

i think i'd rather bring them over manually in a curated fashion

view this post on Zulip Anthony Bullard (Jun 27 2025 at 21:24):

we have a lot of fuzzer crash output in there that won't apply necessarily to the new syntax/compiler

view this post on Zulip Brendan Hansknecht (Jun 28 2025 at 03:09):

We do have a new fuzzer that is just running away

view this post on Zulip Brendan Hansknecht (Jun 28 2025 at 03:09):

Churning out errors

view this post on Zulip Luke Boswell (Jun 28 2025 at 03:10):

oh damn

view this post on Zulip Brendan Hansknecht (Jun 28 2025 at 03:10):

Though generally gets stuck finding the same errors

view this post on Zulip Luke Boswell (Jun 28 2025 at 03:10):

This is the new zig compiler fuzzer? I haven't poked that for a while

view this post on Zulip Brendan Hansknecht (Jun 28 2025 at 03:10):

https://roc-lang.github.io/roc-compiler-fuzz/

view this post on Zulip Luke Boswell (Jun 28 2025 at 03:10):

Oh I forgot about that site :heart_eyes:

view this post on Zulip Luke Boswell (Jun 28 2025 at 03:11):

Would you be interested @Brendan Hansknecht in helping me upgrade that to include the Can stage as well?

view this post on Zulip Luke Boswell (Jun 28 2025 at 03:11):

I've been meaning to get to it but haven't yet

view this post on Zulip Luke Boswell (Jun 28 2025 at 03:12):

we also have the type check stage too

view this post on Zulip Brendan Hansknecht (Jun 28 2025 at 06:41):

If you add a fuzzer to the roc repo with a target, I can easily add it to the site

view this post on Zulip Luke Boswell (Jun 28 2025 at 06:42):

I'll push the changes to the branch so you can see what is there

view this post on Zulip Luke Boswell (Jun 28 2025 at 06:43):

https://github.com/roc-lang/roc/pull/7890

view this post on Zulip Luke Boswell (Jun 28 2025 at 06:43):

If there is anything we don't want I'm happy to clean it up

view this post on Zulip Luke Boswell (Jun 28 2025 at 06:44):

It's also got a bunch of random fuzz fixes in commits too. I was going to bring them across into a separate clean branch, but figure if we want the compiler pipeline fuzzer as a new target, then it's probably ok to just bring everything across together.

view this post on Zulip Luke Boswell (Jun 28 2025 at 06:47):

I've been running the fuzzer using system afl.

view this post on Zulip Joshua Warner (Jun 28 2025 at 16:39):

There’s already a mostly built translator from the old syntax to the new one

view this post on Zulip Joshua Warner (Jun 28 2025 at 16:41):

https://github.com/roc-lang/roc/blob/main/crates/compiler/fmt/src/migrate.rs

view this post on Zulip Luke Boswell (Jun 30 2025 at 07:05):

I've done this here https://github.com/roc-lang/roc/pull/7910

view this post on Zulip Luke Boswell (Jun 30 2025 at 07:06):

Figured we might find a bug from all that fuzzing we did. I found 1 (which I already have a PR in to fix).

So it feels like our new compiler is already more stable than the old.

view this post on Zulip Luke Boswell (Jun 30 2025 at 07:09):

After playing with it a bit, I figure it is helpful having the old syntax verbatim (no migration) in there as a snapshot. There are probably many common error cases that we would like to make nice error reports for.

view this post on Zulip Anton (Jun 30 2025 at 09:39):

Largest Roc PR ever :p ?

view this post on Zulip Luke Boswell (Jun 30 2025 at 10:23):

I didnt think the generated files counted to the line count stats :thinking:

view this post on Zulip Luke Boswell (Jun 30 2025 at 10:25):

Believe it or not, safari on my laptop chokes up in the web interface but my samsung mobile phone is butter smooth. :shrug:

view this post on Zulip Anton (Jun 30 2025 at 10:25):

Need to be smart about your buffering :)

view this post on Zulip Brendan Hansknecht (Jul 01 2025 at 03:13):

This will also give a lot more seeds to the fuzz corpus base which is good


Last updated: Jun 16 2026 at 16:19 UTC