Hi, the website throws an error at me that I don't understand when I try to use the embedded repl:
Is this a known thing? Is my input even valid Roc?
A message was moved here from #beginners > Issues related to type annotations by Rolf Kreibaum.
Looks like a bug in the dev wasm backend
Where would I go to report that? https://github.com/roc-lang/roc/issues or some other place?
I found similar reports in the tracker, so I'll report it there.
Thank you
Moved to https://github.com/roc-lang/roc/issues/6334 and the issue also links back to this chat. Thanks for the quick and friendly replies :-)
Rolf Kreibaum has marked this topic as resolved.
the problem is not specific to the web repl actually
The rockin' roc repl
────────────────────────
Enter an expression, or :help, or :q to quit.
» List.map [0.1,0.2,0.3] (\x -> x*x)
…
thread 'main' panicked at 'not yet implemented: NumMulWrap: layout, Builtin(Decimal)', crates/compiler/gen_dev/src/generic64/mod.rs:1500:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@Brendan Hansknecht what should "mulwrap" for decimals do? just disregard overflow and whatever happens happens?
in practice that would mean that mulWrap
is the same as mulSaturated
. @Richard Feldman may also have an opinion here: what is the behavior we expect multiplication to have for decimals ?
mulWrap
and the like only accept integers
so the behavior I expect is a type mismatch :big_smile:
no? floats implement mulwrap too
or another way to say this is: what would normal mul
do for floats then when they overflow? is that just ignored then?
floats overflow to infinity
I guess there's an argument for extending it to work with any number type
for the sake of Dec performance
so I guess the answer for Dec would be that we would do whatever's fastest and gets the correct answer if there's no overflow
and then if there is overflow, it does something that's probably undesirable but not UB haha
so you'd reach for it for Dec when you want a but more perf and you're really confident it won't overflow
and if it does overflow you're ok with it silently getting the wrong answer if it means more perf
for dec, I think saturated is equivalent in performance to any alternative
in any case, NumWrap should not even be used here. That was a shortcut in the dev backend. I've implemented it properly here https://github.com/roc-lang/roc/pull/6337.
and also fixed a bug that made roc_panic not work (crash worked before, I just messed up an argument type somewhere)
btw, I assume @Brendan Hansknecht is there a reason not to use zig's builtin https://ziglang.org/documentation/master/#toc-mulWithOverflow ?
mulWithOverflow doesn't work cause we don't know if it is an overflow until the Dec has been divided by 10^18.
To multiple 2 decs, we multiply into a i256, then divide by 10^18.
So overflow would be if that final result doesn't fit back into an i128
Last updated: Jul 06 2025 at 12:14 UTC