The following code used to work fine (with roc test), but since August 30th it causes a compilation error:
trigger = |state| {
val = state.num * 10 + 5.U32
{ ..state, num: val }
}
The error is:
── ✗ type mismatch ───────────────────────────────────────── /Users/ageron/test.roc:2:16
The plus method on Dec has an incompatible type.
val = state.num * 10 + 5.U32
^^^^
The method plus has the type:
Dec, Dec -> Dec
But I need it to have the type:
a, U32 -> a where [a.plus : a, U32 -> a, a.times : a, Dec -> a]
All (0) tests passed in 4.4 ms.
The code is equivalent to val = state.num.times(10).plus(5.U32). Perhaps the compiler used to assume that plus and times were homogeneous, therefore since plus takes a U32 as input, its first argument must also be a U32, therefore times must return a U32, therefore it must be U32.times, therefore 10 is a U32 and so is state.num.
I'm guessing there was a breaking change on 30 August where math operations are no longer assumed to be homogeneous? So the compiler doesn't have enough info about the types so it defaults to Dec, and then it cannot find a Dec.plus function that returns a U32. Is this working as intended, or should I file an issue?
Thanks for the report @Aurélien Geron!
I did some digging and this is an unintentional regression, not a deliberate change. I will file an issue.
Last updated: Sep 24 2026 at 15:59 UTC