I found https://github.com/roc-lang/roc/issues/6139 and it appears as though this issue may have the same cause as one I have experienced.
However, this issue seems to be only for Str
s and I was able to replicate a minimal example using List
s, so I was wondering if it would be worth creating another GitHub issue with the following example
app "reference count bug"
packages {
pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br",
}
imports [ pf.Task ]
provides [main] to pf
main = Task.ok {}
expect
in == f in
in = [A, B]
f = \x ->
_ = x |> List.reverse
x
The expectation fails because in == [B, A]
. I would figure that top level declarations would never be mutated, but I'm not sure.
The bug won't happen if you
in
inside the expect block--optimize
flagin
That would be a nice minimal reproducer, would be great to file an issue
Last updated: Jul 05 2025 at 12:14 UTC