Hi everyone! I just started playing with Roc and I've ran into a wall trying to parse some cli args. My code is super simple:
app "hello"
packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.8.1/x8URkvfyi9I0QhmVG98roKBUs_AZRkLFwFJVJ3942YA.tar.br" }
imports [pf.Stdout, pf.Arg, pf.Task]
provides [main] to pf
main =
args <- Arg.list |> Task.await
parsedArgs = Arg.parse argsParser args
dbg parsedArgs
Stdout.write "hi"
argsParser =
Arg.succeed (\name -> \amount -> { name, amount })
|> Arg.withParser (Arg.i64Option { long: "amount" })
|> Arg.withParser (Arg.strOption { long: "name" })
|> Arg.program { name: "test", help: "hey there" }
and then when I try to run it, I get
thread 'main' panicked at 'Error in alias analysis: error in module ModName("UserApp"), function definition FuncName("\x13\x00\x00\x00\x1b\x00\x00\x00c\x05=\x1a\x179\x00F"), definition of value binding ValueId(60): could not find func in module ModName("UserApp") with name FuncName("\x13\x00\x00\x00\x8c\x00\x00\x005K\xf7:8\xfd~\xf7")', crates/compiler/gen_llvm/src/llvm/build.rs:5759:19
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace```
and I'm a bit confused as where I made the mistake. I guess it could be how I use `Arg.program` (name param?) because I wasn't sure looking at the docs what the name should be.
Any help appreciated!
Hi @Piotr Brzeziński,
This is a known issue, this similar example does work. But I'm not sure what the bug-causing difference between them is.
Hey Anton!
Fair enough, thanks for letting me know. I'll go with manual parsing for now then :).
Unfortunately the nice Arg.withParser
API's source code compilation is broken for an undefined time, so only manual parsing of Arg.list
result is possible for now
Piotr Brzeziński has marked this topic as resolved.
Last updated: Jul 06 2025 at 12:14 UTC