Stream: beginners

Topic: Argument has type `List(U8)` but needs to be `List(a)`


view this post on Zulip Ian McLerran (Apr 24 2026 at 02:50):

Hey ya'll, I am trying to port some old code to the zig compiler, but I am running into a strange issue where running roc test tells me that a List of type List(U8) does not match the expected argument of a function which requires List(a). Note that roc check does not complain.

Here is my best minimization of the issue:

Min :: [].{
    func : List(a), (a -> Bool) -> List(List(a))
    func = |list, _f| {
        { acc: [], current: list }
        ->(|{ acc, current }| {
            if !List.is_empty(current)
                acc.append(current)
            else
                acc
        })
    }
}

expect {
    list : List(U8)
    list = []
    res = func(list, |x| x == 0)
    res == []
}
-- TYPE MISMATCH ---------------------------------

The first argument being passed to this function has the wrong type:
   ┌─ /Users/imclerran/source/roc/playground/Min.roc:17:11
   │
17 │     res = func(list, |x| x == 0)
   │                ^^^^

This argument has the type:

    List(U8)

But Min.func needs the first argument to be:

    List(a)
Ran 1 tests in 6.3ms:
    0 passed
    1 failed

FAIL: Min.roc
14 │ expect {
15 │     list : List(U8)
16 │     list = []
17 │     res = func(list, |x| x == 0)
18 │     res == []
19 │ } - hit a runtime error

view this post on Zulip Anton (Apr 24 2026 at 09:51):

I'll check this out

view this post on Zulip Anton (Apr 24 2026 at 11:55):

Fixed in PR#9368


Last updated: May 01 2026 at 12:45 UTC