Stream: beginners

Topic: roc-test-on-mac


view this post on Zulip JesterXL (Dec 01 2022 at 15:14):

Hey, I've managed to get roc repl + compiler to work on my Mac 12.6 Monterey, but roc test gets mad:

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Erroneous', crates/compiler/mono/src/ir.rs:10148:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I tried with/without the app header. I'm following the Roc tutorial docs.

view this post on Zulip Ayaz Hafiz (Dec 01 2022 at 15:15):

What does roc check say? Do you have any type errors?

view this post on Zulip JesterXL (Dec 01 2022 at 15:15):

── MISSING DEFINITION ─────────────────────────────────────────────── main.roc ─

main is listed as exposed, but it isn't defined in this module.

You can fix this by adding a definition for main, or by removing it
from exposes.


── TYPE MISMATCH ──────────────────────────────────────────────────── main.roc ─

This 2nd argument to isEq has an unexpected type:

20if count == 1 then
                     ^

The argument is a number of type:

    Num *

But isEq needs its 2nd argument to be:

    Num * | * has Eq

────────────────────────────────────────────────────────────────────────────────

2 errors and 1 warning found in 14 ms.

view this post on Zulip Ayaz Hafiz (Dec 01 2022 at 15:19):

Yeah, currently we have some bugs if you try to compile a Roc program that has type errors. That type error is a bug; I'm working on fixing it now. In the meantime you can use a type annotation as a workaround (https://roc.zulipchat.com/#narrow/stream/231634-beginners/topic/Type.20mismatch.20in.20if-then-else.20tutorial.20example/near/313227546)

view this post on Zulip Ayaz Hafiz (Dec 01 2022 at 15:21):

Currently roc test does not exit early if there are type errors, which is why you saw the panic above, rather than a type error. We intend to change that soon.

view this post on Zulip JesterXL (Dec 01 2022 at 15:27):

No worries, ok. I tried: pluralize : Str, Str, Num * -> Str and pluralize : Str, Str, Num -> Str, but both seem... off. Do you know what that 3rd param should be?

view this post on Zulip Ayaz Hafiz (Dec 01 2022 at 15:34):

try pluralize : Str, Str, Num a -> Str | a has Eq

view this post on Zulip JesterXL (Dec 01 2022 at 15:42):

Fascinating, same response:

── TYPE MISMATCH ──────────────────────────────────────────────────── main.roc 

This 2nd argument to isEq has an unexpected type:

51      if count == 1 then
                     ^

The argument is a number of type:

    Num *

But isEq needs its 2nd argument to be:

    Num a | a has Eq

view this post on Zulip Ayaz Hafiz (Dec 01 2022 at 15:46):

What if you say

one : Num a | a has Eq
one = 1
if count == one then ...

view this post on Zulip JesterXL (Dec 01 2022 at 15:50):

lol, here's what roc check says:

── TYPE MISMATCH ──────────────────────────────────────────────────── main.roc ─

Something is off with the body of the one definition:

51│  one : Num a | a has Eq
52one = 1
           ^

The body is a number of type:

    Num *

But the type annotation on one says it should be:

    Num a | a has Eq

view this post on Zulip Ayaz Hafiz (Dec 01 2022 at 16:04):

Oh man, I'm sorry. I have a fix here: https://github.com/roc-lang/roc/pull/4644 - if it lands today it'll be in tomorrow's nightly release.

view this post on Zulip JesterXL (Dec 01 2022 at 16:17):

Nooooo worries, it was fun to learn about the types!

view this post on Zulip JesterXL (Dec 01 2022 at 16:17):

Appreciate your help and patience here.

view this post on Zulip Ayaz Hafiz (Dec 01 2022 at 22:59):

The fix for this should be in the nightly release available tomorrow

view this post on Zulip Anton (Dec 02 2022 at 10:51):

New nightly releases are published :)


Last updated: Jul 06 2025 at 12:14 UTC