Stream: bugs

Topic: ✔ Wrongly inferred arguments types


view this post on Zulip MagicMan (Sep 05 2026 at 11:45):

The functions in the compiler error only ever get called with List(U65) -> List(U64). However, the argument type that the compiler inferred is List(Dec) -> List(Dec). I am unsure whether this is an actual bug. My Roc knowledge is still in its infancy.

See repo for details.

roc test ./src/main.roc
── ✗ type mismatch ─────── ~/repos/roc_sort/src/Sort/BubbleSort.roc:31:19

The first argument being passed to this function has the wrong type.

expect Utils.test(BubbleSort.bubble_sort)
                  ^^^^^^^^^^^^^^^^^^^^^^

This argument has the type:

    List(U64) -> List(U64)

But the function needs the first argument to be:

    List(Dec) -> List(Dec)

── ✗ type mismatch ──────── ~/repos/roc_sort/src/Sort/GnomeSort.roc:30:19

The first argument being passed to this function has the wrong type.

expect Utils.test(GnomeSort.gnome_sort)
                  ^^^^^^^^^^^^^^^^^^^^

This argument has the type:

    List(U64) -> List(U64)

But the function needs the first argument to be:

    List(Dec) -> List(Dec)

── ✗ type mismatch ────── ~/repos/roc_sort/src/Sort/OddEvenSort.roc:43:19

The first argument being passed to this function has the wrong type.

expect Utils.test(OddEvenSort.odd_even_sort)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^

This argument has the type:

    List(U64) -> List(U64)

But the function needs the first argument to be:

    List(Dec) -> List(Dec)

All (0) tests passed in 13.5 ms.

When I add this function the compiler error disappears. The weird part is I don't have to use it at all.

bug : (List(U64) -> List(U64)) -> {}
bug = |func| {
    _ = func(unsorted_5)
}

I tried clearing ~/.cache/roc and using --no-cache to no avail.

view this post on Zulip Anton (Sep 05 2026 at 12:00):

Hi @MagicMan,

When the compiler does not have any constraints on a number it defaults to the number type Dec.
So I would use:

unsorted_4 : List(U64)
unsorted_4 = [2, 4, 1, 3]

or

unsorted_4 = [2.U64, 4, 1, 3]

view this post on Zulip Notification Bot (Sep 05 2026 at 12:31):

MagicMan has marked this topic as resolved.


Last updated: Sep 24 2026 at 15:59 UTC