Sorry for this question. I must be missing something simple. I have the code below in a Complex.roc file but when I try and use it in a main.roc I get a segfault (
Segmentation fault (SIGSEGV) in the Roc compiler.
Fault address: 0xb0
) it works if I have the definition of complex in the same file so I assume I am just importing something wrong. Thanks for any help.
Complex :={re: F64, im: F64}.{
is_eq: Complex, Complex -> Bool
is_eq = |a, b| {a.re == b.re and a.im == b.im}
plus: Complex, Complex => Complex
plus = |a, b| {
{
re:a.re+b.re,
im:a.im+b.im
}
}
times = |a, b| {
{
re:a.re*b.re - a.im*b.im,
im:a.re*b.im + a.im*b.re
}
}
}
import Complex
main! = |_args| {
a: Complex
a = {re:1,im:1}
dbg a+a
Ok({})
}
definitely a bug in the compiler! would you mind opening a GitHub issue for this?
https://github.com/roc-lang/roc/issues
(just copy/pasting the code in there and mentioning that it segfaults when you run roc ______ would be great)
Can do! Thanks!
Done. https://github.com/roc-lang/roc/issues/9716
this looks like a relatively quick fix, I'll post here when I have it merged!
Last updated: Jul 23 2026 at 13:15 UTC