Skip to content

LIR panic on type error in expect #9349

@niclas-ahden

Description

@niclas-ahden

roc test panics on a type error in expect:

foo : U64 -> U64
foo = |x| x

expect foo(Dynamite) == 5 # boom!

main! = |_| { Ok({}) }

It doesn't seem to matter what the type error is (tested Dynamite, "bar" etc. with the same result).

Output:

$ roc test --no-cache type_error_expect.roc
thread 265290807 panic: LIR/codegen invariant violated: exprLayout called on non-value expression runtime_error
???:?:?: 0x10967b2ef in ??? (roc)
???:?:?: 0x109837c97 in ??? (roc)
???:?:?: 0x1095f2633 in ??? (roc)
???:?:?: 0x1093db47f in ??? (roc)
???:?:?: 0x109188303 in ??? (roc)
???:?:?: 0x108ed6d4b in ??? (roc)
???:?:?: 0x108e79393 in ??? (roc)
???:?:?: 0x108e66923 in ??? (roc)
???:?:?: 0x108f29b3f in ??? (roc)
???:?:?: 0x108f2b837 in ??? (roc)
???:?:?: 0x108f2bd97 in ??? (roc)
???:?:?: 0x183379d53 in ??? (???)
???:?:?: 0x0 in ??? (???)
zsh: abort      roc test --no-cache type_error_expect.roc

Moving the type error into main! works as intended:

foo : U64 -> U64
foo = |x| x

main! = |_| {
  _ = foo(Dynamite)
  Ok({})
}
$ roc test --no-cache type_error_expect.roc
-- TYPE MISMATCH ---------------------------------

The first argument being passed to this function has the wrong type:
  ┌─ /Users/niclas/dev/roc-maybe-zig/type_error_expect.roc:6:7
  │
6 │   _ = foo(Dynamite)
  │           ^^^^^^^^

This argument has the type:

    [Dynamite, ..]

But foo needs the first argument to be:

    U64

And the same output for a roc run (not roc test).

Tested on macOS 26.3.1 aarch64 using Roc built from commit d38fd084fbe36864c7b336f3b92a9214b6f0e4e7.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions