Roc seems to panic when using static dispatch on built-in generic types with a named lambda:
main! = |_args| {
f = |x| x * 2
result = [1, 2, 3].map(f) # boom!
Ok({})
}
-
It is not limited to List (tested Try with the same result).
-
It is not limited to map (tried fold, filter and got the same result).
-
It happens within expect as well.
-
It does not happen if you:
Inline the lambda:
or use List.map instead of static dispatch:
f = |x| x * 2
List.map([1, 2, 3], f)
or use a nominal-type:
Foo(a) := { value: a }.{
map : Foo(a), (a -> b) -> Foo(b)
map = |w, f| { value: f(w.value) }
}
expect {
f = |x| x * 2
a : Foo(U64)
a = { value: 5 }
a.map(f).value == 10
}
Here's the panic:
$ roc panic_main.roc
thread 265253081 panic: reached unreachable code
???:?:?: 0x109acb84b in ??? (roc)
???:?:?: 0x1098e0df3 in ??? (roc)
???:?:?: 0x1096bc03f in ??? (roc)
???:?:?: 0x109acfc4f in ??? (roc)
???:?:?: 0x109ad1b87 in ??? (roc)
???:?:?: 0x1098e2f93 in ??? (roc)
???:?:?: 0x1096bc03f in ??? (roc)
???:?:?: 0x109acfc4f in ??? (roc)
???:?:?: 0x109ad2773 in ??? (roc)
???:?:?: 0x1098e2873 in ??? (roc)
???:?:?: 0x1096bc03f in ??? (roc)
???:?:?: 0x1094cbd8b in ??? (roc)
???:?:?: 0x109f0e687 in ??? (roc)
???:?:?: 0x109c5e45b in ??? (roc)
???:?:?: 0x109ad08eb in ??? (roc)
???:?:?: 0x1098e219b in ??? (roc)
???:?:?: 0x1096bc03f in ??? (roc)
???:?:?: 0x109acfc4f in ??? (roc)
???:?:?: 0x1098e0847 in ??? (roc)
???:?:?: 0x1096bc03f in ??? (roc)
???:?:?: 0x1094cbd8b in ??? (roc)
???:?:?: 0x109c56df3 in ??? (roc)
???:?:?: 0x109c549fb in ??? (roc)
???:?:?: 0x109acae83 in ??? (roc)
???:?:?: 0x1098e045b in ??? (roc)
???:?:?: 0x1096bbf07 in ??? (roc)
???:?:?: 0x1094cbd8b in ??? (roc)
???:?:?: 0x109299693 in ??? (roc)
???:?:?: 0x10927b363 in ??? (roc)
???:?:?: 0x10901312b in ??? (roc)
???:?:?: 0x108d6d853 in ??? (roc)
???:?:?: 0x108d653fb in ??? (roc)
???:?:?: 0x108d6fce3 in ??? (roc)
???:?:?: 0x108d77ceb in ??? (roc)
???:?:?: 0x108f55d83 in ??? (roc)
???:?:?: 0x108f57837 in ??? (roc)
???:?:?: 0x108f57d97 in ??? (roc)
???:?:?: 0x183379d53 in ??? (???)
???:?:?: 0x0 in ??? (???)
zsh: abort roc panic_main.roc
Here's an expect example:
expect {
f = |x| x * 2
[1, 2, 3].map(f) == [2, 4, 6] # boom!
}
Output:
$ roc test panic_expect.roc
thread 265253479 panic: reached unreachable code
???:?:?: 0x108cd784b in ??? (roc)
???:?:?: 0x108aecdf3 in ??? (roc)
???:?:?: 0x1088c816f in ??? (roc)
???:?:?: 0x108cdbc4f in ??? (roc)
???:?:?: 0x108cddb87 in ??? (roc)
???:?:?: 0x108aeee27 in ??? (roc)
???:?:?: 0x1088c816f in ??? (roc)
???:?:?: 0x108cdbc4f in ??? (roc)
???:?:?: 0x108aeca6b in ??? (roc)
???:?:?: 0x1088c816f in ??? (roc)
???:?:?: 0x1086d7d8b in ??? (roc)
???:?:?: 0x108aee91b in ??? (roc)
???:?:?: 0x1088c816f in ??? (roc)
???:?:?: 0x1086d7d8b in ??? (roc)
???:?:?: 0x1084a5693 in ??? (roc)
???:?:?: 0x108487363 in ??? (roc)
???:?:?: 0x10821f12b in ??? (roc)
???:?:?: 0x10810e20f in ??? (roc)
???:?:?: 0x1080b1393 in ??? (roc)
???:?:?: 0x10809e923 in ??? (roc)
???:?:?: 0x108161b3f in ??? (roc)
???:?:?: 0x108163837 in ??? (roc)
???:?:?: 0x108163d97 in ??? (roc)
???:?:?: 0x183379d53 in ??? (???)
???:?:?: 0x0 in ??? (???)
zsh: abort roc test panic_expect.roc
Tested on macOS 26.3.1 aarch64 using Roc built from commit d38fd084fbe36864c7b336f3b92a9214b6f0e4e7.
Roc seems to panic when using static dispatch on built-in generic types with a named lambda:
It is not limited to
List(testedTrywith the same result).It is not limited to
map(triedfold,filterand got the same result).It happens within
expectas well.It does not happen if you:
Inline the lambda:
or use
List.mapinstead of static dispatch:or use a nominal-type:
Here's the panic:
Here's an
expectexample:Output:
Tested on macOS 26.3.1 aarch64 using Roc built from commit
d38fd084fbe36864c7b336f3b92a9214b6f0e4e7.