Stream: beginners

Topic: Congrats on all the awesome progress + bug report


view this post on Zulip Ian McLerran (Dec 22 2025 at 23:09):

Hey ya'll, just coming back to roc after being a way for a while. So much progress on the new compiler... I can't believe how far it has come! Congrats on all the amazing progress! :partying_face:

Just found a bug with the new List.map implementation. It seems that calling List.map on an empty list causes a runtime crash:

Roc crashed: Internal error: TypeMismatch in for_iterate continuation

view this post on Zulip Ian McLerran (Dec 22 2025 at 23:10):

Min repro:

app [main!] { pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.6/2BfGn4M9uWJNhDVeMghGeXNVDFijMfPsmmVeo6M4QjKX.tar.zst" }

main! = |_args| {
    l = List.map([], |_| 0)
    dbg l
    Ok({})
}

Roc version:

Roc compiler version release-fast-4b857fa1

view this post on Zulip Richard Feldman (Dec 22 2025 at 23:17):

hey @Ian McLerran! Great to see you! :smiley:

view this post on Zulip Richard Feldman (Dec 22 2025 at 23:17):

would you mind opening a gh issue for it?

view this post on Zulip Ian McLerran (Dec 22 2025 at 23:20):

Good to be back! :smiley: I absolutely can do!

view this post on Zulip Ian McLerran (Dec 23 2025 at 01:45):

Issue at #8722

view this post on Zulip Ian McLerran (Dec 23 2025 at 02:33):

Just for my own edification and understanding of the current compiler design, I see that the TypeMismatch error is being thrown by for_iterate. From what I can see, for_iterate only exists in interpreter.zig. However this issue obviously(?) occured in compiled code.

I had assumed that the interpreter is not invoked for compiled roc code, but I believe I may have had a wrong understanding of the new compiler architecture (admittedly my understanding is only slightly above nil).

Can anyone clarify for me why I am seeing code from interpreter.zig appearing to crash in compiled(?) roc code?

view this post on Zulip Luke Boswell (Dec 23 2025 at 03:52):

We only have an interpreter... there is no lowering to machine code or llvm yet

view this post on Zulip Luke Boswell (Dec 23 2025 at 03:53):

When you do roc build we using an interpreter shim to link with the platform host (the platform author doesn't need to change a thing - the ABI is the same).

view this post on Zulip Luke Boswell (Dec 23 2025 at 03:54):

Once we have a llvm backend we can use that optimised machine code instead of the shim.

view this post on Zulip Luke Boswell (Dec 23 2025 at 03:56):

For running roc in a dev loop, i.e. roc path/to/app.roc the design is to always ise an interpreter for really fast startup time.

Though it is currently a bit of an experiment as to whether an interpreter will provide a sufficiently fast enough runtime performancs. The alternative would be to reinstate our dev backends but that re-introduces (slow) linking into the workflow.

view this post on Zulip Richard Feldman (Dec 23 2025 at 13:06):

actually we don't have to reintroduce linking into the dev workflow - we can use the same "prebuilt host shim" strategy we do for the interpreter, just have it execute the compiled bytes instead of running an interpreter :smile:

view this post on Zulip Fabian Schmalzried (Dec 23 2025 at 18:49):

Ian McLerran said:

Issue at #8722

Will be fixed in #8725


Last updated: Jan 12 2026 at 12:19 UTC