I'm getting nowhere trying to solve a bug in my code. I keep getting:
── ✗ missing method ───────────────────────────────────────────────────────────────────────────────── Allergies.roc:29:7
This to_hash call is on a value whose type never resolved to a concrete type, so it has no to_hash method.
d = set(3)
^^^
Using the value somewhere that requires a specific type, or annotating it, will give it one.
What am I doing wrong? It seems to be a problem with Set.from_list(). Is it because there isn't a to_hash function for Allergen? Can I make it use a default to_hash?
My code is:
Allergies :: {}.{
Allergen : [Eggs, Peanuts, Shellfish, Strawberries, Tomatoes, Chocolate, Pollen, Cats]
allergic_to : Allergen, U64 -> Bool
allergic_to = |allergen, score| {
set(score).contains(allergen)
}
set : U64 -> Set(Allergen)
set = |score| {
[1, 2, 4, 8, 16, 32, 64, 128].keep_if(|n| score.bitwise_and(n) > 0)
|> List.map(
|n| match n {
1 => Eggs
2 => Peanuts
4 => Shellfish
8 => Strawberries
16 => Tomatoes
32 => Chocolate
64 => Pollen
128 => Cats
_ => crash "Invalid score"
},
)
|> Set.from_list()
}
expect {
d = set(3)
dbg d
d.contains(Eggs) == Bool.True
}
}
Hi @Oliver,
I just tried it and your code works on the latest nightly 2026-10-30, can you try that version and let me know if that solves it for you as well?
By the way, Allergen is a tag union so the compiler knows how to hash it.
Amazing. Thank you. I should have tried that first. I was using a version from 21st Oct, but evidently something relevant has changed since then. Thank you.
This issue was resolved a few days ago:
https://github.com/roc-lang/roc/issues/12521
Last updated: Nov 04 2026 at 18:54 UTC