Stream: beginners

Topic: Segfault when using a type from a file


view this post on Zulip Timothy Daniel (Jun 19 2026 at 18:28):

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({})
}

view this post on Zulip Richard Feldman (Jun 19 2026 at 18:29):

definitely a bug in the compiler! would you mind opening a GitHub issue for this?

https://github.com/roc-lang/roc/issues

view this post on Zulip Richard Feldman (Jun 19 2026 at 18:30):

(just copy/pasting the code in there and mentioning that it segfaults when you run roc ______ would be great)

view this post on Zulip Timothy Daniel (Jun 19 2026 at 18:30):

Can do! Thanks!

view this post on Zulip Timothy Daniel (Jun 19 2026 at 18:38):

Done. https://github.com/roc-lang/roc/issues/9716

view this post on Zulip Richard Feldman (Jun 19 2026 at 19:03):

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