Stream: bugs

Topic: Number misinterpretation bug


view this post on Zulip Artur Domurad (Nov 30 2025 at 17:33):

Getting unexpected results from:

app [main!] { pf: platform "../roc/test/fx/platform/main.roc" }

import pf.Stdout

main! = || {
    result = sum_lambda(2400)

    dbg result
    Stdout.line!("Stdout: ${result.to_str()}")
}

sum_lambda : U64 -> U64
sum_lambda = |num| sum(num)

# sum : U64 -> U64
sum = |num| {
    0 + num
}

Output:

ROC DBG: 2400
Stdout: 1923270417758289920

Works correctly when I comment out the sum_lambda type:

ROC DBG: 2400
Stdout: 2400.0

and also when I uncomment the type of sum:

ROC DBG: 2400
Stdout: 2400

I can see the same problem for all number types - except Dec.
Using current "Roc compiler version debug-9a5eb3c9"

view this post on Zulip Luke Boswell (Nov 30 2025 at 17:37):

I think it's a double decref bug -- is my guess

view this post on Zulip Luke Boswell (Nov 30 2025 at 17:37):

Hopefully my current patches will resolve this class of bugs more generally

view this post on Zulip Luke Boswell (Nov 30 2025 at 17:37):

Or maybe there is something going funny with the type annotation

view this post on Zulip Richard Feldman (Nov 30 2025 at 17:42):

I can look into it after Luke's stuff lands


Last updated: Dec 21 2025 at 12:15 UTC