Stream: compiler development

Topic: don't warn on unconditional conditions in unit tests


view this post on Zulip Romain Lepert (Jun 28 2026 at 07:59):

This PR is a nice addition in the general case
https://github.com/roc-lang/roc/pull/9816

However it triggers on all my unit tests where i intentionally build inputs to test a deterministic pattern in a match statement (e.g. test Ok or Err cases). Not sure how to account for both use cases though ...

view this post on Zulip Richard Feldman (Jun 28 2026 at 15:21):

hm, can you show an example of one of these tests?

view this post on Zulip Romain Lepert (Jun 28 2026 at 22:42):

here is a toy example

Color : [Blue, Red]

get_favorite_color : (Str) -> Color
get_favorite_color = |name| {
    if name == "Bob" {
        Blue
    } else {
        Red
    }
}

expect match get_favorite_color("Bob") {
    Blue => Bool.True
    _ => Bool.False
}
UNCONDITIONAL CONDITION
This match value is known at compile time, so this match will always inspect the same value.

view this post on Zulip Luke Boswell (Jun 28 2026 at 22:46):

Are expect's evaluated at compile time?

view this post on Zulip Luke Boswell (Jun 28 2026 at 22:47):

Like not roc test but roc build is doing this?

view this post on Zulip Richard Feldman (Jun 28 2026 at 22:55):

I assume this is roc test

view this post on Zulip Richard Feldman (Jun 28 2026 at 22:55):

but roc test has its constants get evaluated at compile-time just like everything else, so it makes sense from the compiler's perspective to flag this :smile:

view this post on Zulip Richard Feldman (Jun 28 2026 at 22:56):

I think we just need to disable that check inside expect

view this post on Zulip Richard Feldman (Jun 28 2026 at 22:57):

actually I guess even roc check would flag it

view this post on Zulip Romain Lepert (Jun 28 2026 at 22:58):

it shows up in all cases

10% ❯ roc examples/bugs/unconditional_conditional.roc

┌─────────────────────────┐
│ UNCONDITIONAL CONDITION ├─ This match value is known at compile time, so this match will always inspect the same value. ──────────────────────────┐
└┬────────────────────────┘                                                                                                                         │
 │                                                                                                                                                  │
 │  expect match get_messages("Bob") {                                                                                                              │
 │               ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾                                                                                                                │
 └────────────────────── /var/folders/6t/1pxgxq6x3z5279ljlxshg2nc0000gn/T/roc/release-fast-26ecddf3/Vo9KUFE5LHdQ2vChgIPqlQkHThUTjpdX/main.roc:18:14 ┘



Found 0 error(s) and 1 warning(s) for /var/folders/6t/1pxgxq6x3z5279ljlxshg2nc0000gn/T/roc/release-fast-26ecddf3/Vo9KUFE5LHdQ2vChgIPqlQkHThUTjpdX/main.roc.

terrocotta on  main [!?] via ↯ v0.16.0
󰂃 10% ❯ roc build examples/bugs/unconditional_conditional.roc

┌─────────────────────────┐
│ UNCONDITIONAL CONDITION ├─ This match value is known at compile time, so ───┐
└┬────────────────────────┘  this match will always inspect the same value.   │
 │                                                                            │
 │  expect match get_messages("Bob") {                                        │
 │               ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾                                          │
 └────────────────────────────────────────────────────────────────────────────┘
    /var/folders/6t/1pxgxq6x3z5279ljlxshg2nc0000gn/T/roc/release-fast-26ecddf3/N01parxE2JborsMqhPcXgNd8BuiPF8SO/unconditional_conditional.roc:18:14


0 errors and 1 warning found in 56ms while successfully building:

    unconditional_conditional

terrocotta on  main [!?] via ↯ v0.16.0
󰂃 10% ❯ roc test examples/bugs/unconditional_conditional.roc
All (1) tests passed in 10.0 ms.

┌─────────────────────────┐
│ UNCONDITIONAL CONDITION ├─ This match value is known at compile time, so ───┐
└┬────────────────────────┘  this match will always inspect the same value.   │
 │                                                                            │
 │  expect match get_messages("Bob") {                                        │
 │               ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾                                          │
 └────────────────────────────────────────────────────────────────────────────┘
    /Users/romain/Projects/terrocotta/examples/bugs/unconditional_conditional.roc:12:14

view this post on Zulip Richard Feldman (Jun 28 2026 at 23:01):

yeah I'll push a fix for this!

view this post on Zulip Richard Feldman (Jun 28 2026 at 23:36):

PR for this: https://github.com/roc-lang/roc/pull/9863

view this post on Zulip Richard Feldman (Jun 29 2026 at 20:08):

@Romain Lepert landed - lmk if that fixes it for you!

view this post on Zulip Romain Lepert (Jun 30 2026 at 19:18):

it works on roc_nightly-2026-06-30-09084da :)


Last updated: Jul 23 2026 at 13:15 UTC