I have the following function
keep_oks : List(a), (a -> Try(ok, _err)) -> List(ok)
keep_oks = |list, fun| {
var $dest = []
for elem in list {
match fun(elem) {
Ok(ok_val) => {
$dest = $dest.append(ok_val)
}
Err(_) => {
$dest = $dest
}
}
}
$dest
}
and the following uses
main! = |_args| {
always_ok_n = |_| Ok(1)
always_ok_tag = |_| Ok(Res)
equal_nums = (keep_oks([10], always_ok_n) == [1])
print!(equal_nums)
# Panics 90% of the time
equal_tag = (keep_oks([10], always_ok_tag) == [Res])
print!(equal_tag)
Ok({})
}
The former comparison, equal_nums is fine, but the latter leads to a panic 90% of the time under roc --no-cache. Didn't get that far debugging it because I can't yet get the symbols to be not stripped, but I believe it's because an assertion in asRocList (called in callLowLevelBuiltin for list_append) is failing. The other 10% of the time it works just fine :shrug: Rewriting in fold style (as opposed to for-loop) doesn't change anything.
Last updated: Mar 20 2026 at 12:28 UTC