While trying to cast an U8 integer to I64 in the REPL I get the following error:
Enter an expression, or :help, or :q to quit.
» Num.toI64 3u8
thread 'main' panicked at crates/compiler/gen_dev/src/generic64/mod.rs:4775:22:
not yet implemented: int cast from U8 to I64
And indeed, line 4775 of crates/compiler/gen_dev/src/generic64/mod.rs
is:
_ => todo!("int cast from {source:?} to {target:?}"),
Is there some fundamental reason this (and similar) integer casts are not supported yet? This particular case seems rather obvious, at least to my unsuspecting and unexperienced eye. In the online REPL it works as desired:
» Num.toI64 3u8
3 : I64
I couldn't find a github issue that tracks this problem.
What arch are you on? I think the REPL uses the dev backends, which are still filling out these APIs. Wasm is the most mature, then x64 I think.
@shua probably would know the status here. They've been chipping away at these functions. :grinning_face_with_smiling_eyes:
Thanks! I'm on x86_64.
If I can take some more of your time... What do you mean by "dev backends"?
Does that mean that the compiler should handle it and the problem only occurs in the REPL? (I didn't try it.)
Is there some document that gives an overview of the architecture of the compiler/REPL/standard library/other important parts of the language that I'm not aware of?
When we compile Roc, it first gets parsed and typechecked and all, and that result gets saved as IR, or an Intermediate Representation. It's a generic, high-level way to say "this is a function, and this is a number, etc." Depending on where and how we want to run the program, we have different "backends" to convert this IR to something the machine can run
One of them is LLVM, which is what Rust and Swift and all use, it spits out fast code but it's slow to compile
See en.wikipedia.org/wiki/Frontend_and_backend
The roc compiler has three backends.
Yeah, what he said
Ah, ok, so the "dev backends" are the backends designed to be used during development, allowing for fast iteration (at the cost of bad runtime performance). Now I see what the "dev" stands for in this context. Thanks for explaining this!
Last updated: Jul 06 2025 at 12:14 UTC