Stream: bugs

Topic: Default `to_hash` breaking change?


view this post on Zulip Aurélien Geron (Sep 08 2026 at 23:30):

The following code worked until 2026-09-07:

Tree := [Node({ label : Str, children : Set(Tree) })].{}

main! = |_args| {
    tree = Tree.(Node({
        label: "root",
        children: Set.single(Tree.(Node({
            label: "child",
            children: Set.empty()
        })))
    }))
    dbg tree
    Ok({})
}

It outputs this:

[dbg] Node({ children: Set.from_list([Node({ children: Set.from_list([]), label: "child" })]), label: "root" })

However, since the 2026-09-08 nightly, I get this error:

── ✗ missing method ───────────────────────────────────────────────────────────────────────────────── tree-test.roc:9:13

This is_eq method is being called on a value whose type doesn't have that method.

children: Set.single(Tree.(Node({
          ^^^^^^^^^^

The value's type, which does not have a method named is_eq, is:

    Tree

Hint: For this to work, the type would need to have a method named is_eq associated with it in the type's declaration.

── ✗ missing method ───────────────────────────────────────────────────────────────────────────────── tree-test.roc:9:13

This to_hash method is being called on a value whose type doesn't have that method.

children: Set.single(Tree.(Node({
          ^^^^^^^^^^

The value's type, which does not have a method named to_hash, is:

    Tree

Hint: For this to work, the type would need to have a method named to_hash associated with it in the type's declaration.

── 2 errors and 0 warnings ─────────────────────────────────────────────────────────────────────────────── tree-test.roc

Roc application crashed with this message:

        runtime error

The fix is easy, just add is_eq : _ and to_hash : _ to the Tree type:

Tree := [Node({ label : Str, children : Set(Tree) })].{
    is_eq : _
    to_hash : _
}

This seems like a reasonable error, and the fix is easy, so if this is intended, perhaps announce it as a breaking change (although it's arguably a bug fix)?

view this post on Zulip Richard Feldman (Sep 09 2026 at 01:24):

yeah this is a bug fix...that code never should have passed type-checking :sweat_smile:


Last updated: Sep 24 2026 at 15:59 UTC