Stream: bugs

Topic: "Hit an erroneous type when creating a layout for <Type>.."


view this post on Zulip Austin Davis (Mar 18 2025 at 04:28):

I ran into this error message, and I don't really know enough about the compiler to understand what is causing it:

This expectation crashed while running:

76│>  expect
77│>      from_list([(1, "1"), (2, "2"), (3, "3"), (4, "4")])
78│>      == (
79│>          empty({})
80│>          |> insert(1, "1")
81│>          |> insert(2, "2")
82│>          |> insert(3, "3")
83│>          |> insert(4, "4")

The crash reported this message:

Hit an erroneous type when creating a layout for `AvlTreeNum.IdentId(6)`

Can anyone help me out with this one?

view this post on Zulip Anton (Mar 18 2025 at 09:24):

Hi @Austin Davis,
I could not reproduce this crash myself, can you share a complete roc file?

view this post on Zulip Austin Davis (Mar 18 2025 at 19:40):

@Anton Here is a public repo for a Roc package that should reproduce the error when running roc test from the /package directory.

https://github.com/austindd/roc-data-structures

I was working from a different repo to flesh out some ideas, but I moved it to a fresh repo that (currently) only includes the modules I needed to reproduce the error.

view this post on Zulip Austin Davis (Mar 18 2025 at 19:41):

The error occurs when running AvlTreeNum.from_list. The other functions seem to work fine.

view this post on Zulip Anton (Mar 19 2025 at 12:32):

The fix ended up quite simple :)
Add & Inspect to the type signature of AvlTreeBase.fromList:

from_list : List (a, b) -> AvlTreeBase a b where a implements Ord & Inspect

We will probably not improve that error message because we're working on a completely new compiler.

view this post on Zulip Anton (Mar 19 2025 at 12:34):

By the way, it's recommended to use intermediary variables (tree_a,tree_b) for more helpful test output:

This expectation failed:

77│>  expect
78│>      tree_a = from_list([(1, "1"), (2, "2"), (3, "3"), (4, "4")])
79│>      tree_b = (
80│>          empty({})
81│>          |> insert(1, "1")
82│>          |> insert(2, "2")
83│>          |> insert(3, "3")
84│>          |> insert(4, "4")
85│>      )
86│>
87│>      tree_a == tree_b

When it failed, these variables had these values:

tree_a : AvlTreeNum a Str
tree_a = @AvlTreeNum (Node { h: 2, k: @NumKey 2, l: Leaf { k: @NumKey 1, v: "1" }, r: Leaf { k: @NumKey 3, v: "3" }, v: "2" })

tree_b : AvlTreeNum a Str
tree_b = @AvlTreeNum (Node { h: 3, k: @NumKey 2, l: Leaf { k: @NumKey 1, v: "1" }, r: Node { h: 2, k: @NumKey 4, l: Leaf { k: @NumKey 3, v: "3" }, r: Empty, v: "4" }, v: "2" })


1 failed and 0 passed in 197 ms.

view this post on Zulip Austin Davis (Mar 19 2025 at 20:01):

Amazing, thank you for the help @Anton !


Last updated: Jul 06 2025 at 12:14 UTC