Stream: beginners

Topic: Example that hangs the roc type checker (but only locally)


view this post on Zulip cerk (Aug 06 2026 at 22:55):

Just messing around with Roc again and I wrote this incorrect code:

main! = |_args| {
    a = ["Larry", "Curly", "Moe"]
    b = a.swap(0, 2)
    echo!("${Str.inspect(b.get(0))}\n")
    Ok({})
}

Since b is of type Try, it doesn't make sense to call get on it. When I attempt to run this program with Roc, it appears to enter an infinite loop during type checking. However, if I run this code on the Roc website, it responds with the correct error: This get method is being called on a value whose type doesn't have that method.

Roc compiler version nightly-2026-08-06-61bbb59

I'm not confident enough to know if this needs reporting or not since it works on the website.

Thanks for reading!

view this post on Zulip Luke Boswell (Aug 06 2026 at 23:04):

Sounds like a bug if its in an infinite loop, a GH issue would be appreciated :smile:

view this post on Zulip cerk (Aug 06 2026 at 23:12):

Ok, here it is:

#10654


Last updated: Aug 12 2026 at 12:35 UTC