I started to write a parser using the modules in the parser example, and everything worked fine until I wanted to write a recursive parser. I used lazy
to avoid the cyclic reference like I would with elm/parser
and roc check
returned 0 errors. However, when I run my tests, the compiler seems to stack overflow.
Is this a known bug?
Here's the parser source
Weirdly, if I remove the parser type annotations, I get a different error instead of the stack overflow:
An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: https://github.com/roc-lang/roc/issues/new/choose
thread '<unnamed>' panicked at 'I thought a non-nullable-unwrapped variant for a lambda set was impossible: how could such a lambda set be created without a base case?', crates/compiler/mono/src/layout.rs:1711:61
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I know we have lots of bugs around recursive types, but I don't know if this one is unique. It probably is; if you can minimize it, can you make an issue Agus? Even if you can't minimize it, capturing a reference to the program for later would be helpful
The second is a known issue. I don't currently know of a good path forward there, but what the problem is is well known
Sounds good. I'll try to minimize it as much as possible and will open an issue later.
https://github.com/roc-lang/roc/issues/5682
I think I boiled it down quite a bit while keeping context
If that's not enough, let me know and I'll try to make a more abstract reproduction without any of the parser stuff
Thanks! Is it possible to get rid of the basic cli dependency and reproduce the bug only in expects? (basic-cli is a pretty big dependency.) And, are all of the expects in your example program necessary to reproduce the issue?
Good point. I started with app because I initially had all the actual parser logic but now that I don't, we don't need that. I will just make an interface.
Updated!
thanks!
Added the abstract example which reproduces this in only a few lines. It would never make sense to run because there's no exit condition, but I think roc should still compile it.
Ha. Found a workaround! Just gotta rewrap the Parser
.
Last updated: Jul 05 2025 at 12:14 UTC