Stream: beginners

Topic: Compiler panic


view this post on Zulip Ben (Jan 29 2025 at 04:59):

Hello, new to functional programming and Roc. Trying to write a function that parses a grid of space separated numbers into a matrix. This is my attempt:

app [main!] {
    pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/bi5zubJ-_Hva9vxxPq4kNx4WHX6oFs8OP6Ad0tCYlrY.tar.br",
}

import pf.Stdin

parse_record : Str -> List U64
parse_record = |text|
    text |> Str.split_on(" ") |> List.keep_oks Str.to_u64

parse_matrix : Str -> List List U64
parse_matrix = |text|
    text |> Str.split_on("\n") |> List.map parse_record

main! = |_args|
    text = Stdin.read_to_end!({})? |> Str.from_utf8?
    _ = text |> parse_matrix
    Ok {}

Compiler is panicing though:

thread 'main' panicked at crates/compiler/mono/src/borrow.rs:361:34:
internal error: entered unreachable code:
        No borrow signature for LambdaName { name: `List.keep_oks`, niche: Niche(Captures([])) } layout.

        Tip 1: This can happen when you call a function with fewer arguments than it expects.
        Like `Arg.list!` instead of `Arg.list! {}`.
        Tip 2: `roc check yourfile.roc` can sometimes give you a helpful error.

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

view this post on Zulip Luke Boswell (Jan 29 2025 at 05:00):

I suspect List List U64 should be `List (List U64)

view this post on Zulip Ben (Jan 29 2025 at 05:01):

That fixed it! Thanks Luke :)

view this post on Zulip Ben (Jan 29 2025 at 05:02):

Does List List U64 make sense / parse as another valid type?

view this post on Zulip Luke Boswell (Jan 29 2025 at 05:03):

To nest types you need the parens :smile: so no it doesn't because List a only has one type variable

view this post on Zulip Sam Mohr (Jan 29 2025 at 05:16):

This is a known issue, I haven't finished my solution. In short, we would have a type error here for most types, but those defined internally in Zig and not Roc aren't type checked on if they got the right number of args

view this post on Zulip Sam Mohr (Jan 29 2025 at 05:17):

I have a branch with a partial fix, but I've been busy with other stuff

view this post on Zulip Anton (Jan 29 2025 at 09:26):

Linking to the issue #7357
I've changed it to a high priority, this List List issue has already been reported 4 times that I know of.


Last updated: Jul 26 2025 at 12:14 UTC