Here is some code:
Gap := {lo: U64, hi: U64}.{
mid : Gap -> U64
mid = |g| {
(g.lo + g.hi) / 2
}
min_max : Gap, Gap -> Gap
min_max = |a, b| {
{lo: a.lo.min(b.lo), hi: a.hi.max(b.hi)}
}
}
main! = |_args| {
a = {lo: 0, hi: 10}
b = {lo: 11, hi: 20}
dbg a.mid()
dbg a.min_max(b)
Ok({})
}
With Roc compiler version nightly-2026-08-26-b29bef3, I am getting missing method errors for the a.mid() and a.min_max(b) calls.
If I change the dbg a.mid() line to dbg Gap.mid(a), then the program runs successfully:
Gap := {lo: U64, hi: U64}.{
mid : Gap -> U64
mid = |g| {
(g.lo + g.hi) / 2
}
min_max : Gap, Gap -> Gap
min_max = |a, b| {
{lo: a.lo.min(b.lo), hi: a.hi.max(b.hi)}
}
}
main! = |_args| {
a = {lo: 0, hi: 10}
b = {lo: 11, hi: 20}
dbg Gap.mid(a)
dbg a.min_max(b)
Ok({})
}
I'm not sure what the correct behavior is supposed to be here but by changing that one line, the missing method error for a.min_max(b) disappears. Should I report a bug on github?
this is correct behavior, unless roc knows that the a and b are explicitly typed at Gap, it infers as plain records, which do not have those methods defined
you can give a/b an annotation, or construct like Gap.{ .. } to tell roc the type
Last updated: Sep 03 2026 at 15:16 UTC