Hi,
I can't understand why my program is panicking, could you help me?
app [main] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br",
}
import pf.Stdout
import pf.Task
displayBlock = \{ widget ? None } ->
when widget is
None -> "{}"
w -> "{ $(displayWidget w) }"
displayGroup = \group ->
"[$(group.widgets |> List.map displayWidget |> Str.joinWith ", ")]"
displayWidget = \widget ->
when widget is
Block block -> "block $(displayBlock block)"
Group group -> "group $(displayGroup group)"
None -> ""
main =
# works
Stdout.line! (displayWidget (Block {}))
Stdout.line! (displayWidget (Group { widgets: [] }))
Stdout.line! (displayWidget (Block { widget: Group { widgets: [] } }))
# fails with panic
Stdout.line! (displayWidget (Block { widget: Block {} }))
thread 'main' panicked at crates/compiler/gen_llvm/src/llvm/build.rs:5764:19:
Error in alias analysis: error in module ModName("UserApp"), function definition FuncName("\x11\x00\x00\x00\x11\x00\x00\x00\xb4e[-\xa6\x8d\x12P"), definition of value binding ValueId(4): expected type '("UserApp"::"\xbf\xb4\xe0\xb0\xed\x84F\x9d",)', found type '((),)'
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I think the compiler is confused trying to figure out the types and you have a bug with type definitions
I'm pretty sure that Block { widget: Block {} }
is an impossible type*.
Cause a block takes a record that contains a widget, but the inner block is taking an empty record
That said, the types in this program are extra strange. I think that the compiler is generating two different versions of Block
, but they can't be used together.
I would try to explictly write out the types, I think that will reveal the issues.
My current guess as to the types is:
Widget : [
Block {widget: Widget},
Group (List Widget),
None
]
Note, that type does not include Block {}
.
I'm honestly a bit surprised these two lines compile together:
Stdout.line! (displayWidget (Block {}))
Stdout.line! (displayWidget (Block { widget: Group { widgets: [] } }))
Looking at the ir, this compiles cause roc is generating two distinct versions of displayWidget
that accept different types.
One version accepts the Widget
type I specified above.
The other accepts the version with Block {}
as a variant
Thank you for your reply, I tried with your type (a bit modified to have a record) and I get compiler issue this time:
app [main] {
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br",
}
import pf.Stdout
import pf.Task
Widget : [
Block { widget : Widget },
Group { widgets : List Widget },
None,
]
displayBlock = \{ widget } ->
when widget is
None -> "{}"
w -> "{ $(displayWidget w) }"
displayGroup = \group ->
"[$(group.widgets |> List.map displayWidget |> Str.joinWith ", ")]"
displayWidget : Widget -> Str
displayWidget = \widget ->
when widget is
Block block -> "block $(displayBlock block)"
Group group -> "group $(displayGroup group)"
None -> "unknown"
main =
Stdout.line! (displayWidget (Block { widget: None }))
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 crates/compiler/mono/src/layout.rs:1589:17:
no lambda set found for (`17.IdentId(4)`, []): LambdaSet {
set: [],
args: [
InLayout(
91,
),
],
ret: InLayout(STR),
representation: InLayout(VOID),
full_layout: InLayout(
103,
),
}
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Hmm....definitely a compiler bug. I'm really not sure the cause.
Some reason commenting out the type is a workaround
Last updated: Jul 26 2025 at 12:14 UTC