When roc test encounters a type error it reports that the tests pass:
foo : U64, (U64 -> U64) -> U64
foo = |x, f| f(x)
expect foo(5, Dynamite) == 5
main! = |_| Ok({})
Output:
$ roc test --no-cache type_error_expect.roc
-- TYPE MISMATCH ---------------------------------
The second argument being passed to this function has the wrong type:
┌─ /Users/niclas/dev/roc-maybe-zig/type_error_expect.roc:4:8
│
4 │ expect foo(5, Dynamite) == 5
│ ^^^^^^^^
This argument has the type:
[Dynamite, ..]
But foo needs the second argument to be:
U64 -> U64
-- COMPTIME EVAL ERROR ---------------------------
This definition could not be evaluated at compile time:
┌─ /Users/niclas/dev/roc-maybe-zig/type_error_expect.roc:4:28
│
4 │ expect foo(5, Dynamite) == 5
│ ^
The evaluation failed with error:
Numeric literal cannot be used as this type (type doesn't support from_numeral)
Ran 1 tests in 13.6ms:
1 passed
0 failed
- If I add another test (
expect 1 == 1) it will report that both tests passed.
- It doesn't seem to matter what the type error is (tested with a string instead of
Dynamite with the same result).
- It seems to be limited to type errors, not all types of compilation failure. If I remove the
main! function it prints an error about that but the test does not pass:
Output:
$ roc test --no-cache type_error_expect.roc
-- MISSING MAIN! FUNCTION ------------------------
Default app modules must have a main! function.
No main! function was found.
Add a main! function like:
main! = |arg| { ... }
┌─ /Users/niclas/dev/roc-maybe-zig/type_error_expect.roc:1:1
│
1 │ expect 1 == 2
│ ^^^^^^^^^^^^^
Ran 1 tests in 11.2ms:
0 passed
1 failed
FAIL: type_error_expect.roc
1 │ expect 1 == 2
Tested on macOS 26.3.1 aarch64 using Roc built from commit d38fd084fbe36864c7b336f3b92a9214b6f0e4e7.
When
roc testencounters a type error it reports that the tests pass:Output:
expect 1 == 1) it will report that both tests passed.Dynamitewith the same result).main!function it prints an error about that but the test does not pass:Tested on macOS 26.3.1 aarch64 using Roc built from commit
d38fd084fbe36864c7b336f3b92a9214b6f0e4e7.