Stream: beginners

Topic: ✔ confused with compile error


view this post on Zulip Steven Chen (Dec 18 2023 at 17:17):

I have this code snippet:

mainLoop = \x ->
    _ <- Stdout.line "hello \(Num.toStr x)" |> Task.await
    if x == 3 then
        Task.ok {}
    else
        mainLoop (x + 1)

main =
    mainLoop 0

roc check passes without issues. But when I build, roc gives me this error I can't understand:

thread 'main' panicked at 'Error in alias analysis: error in module ModName("UserApp"), function definition FuncName("\x13\x00\x00\x00\x02\x00\x00\x00\x94B\xe9\x05\x0em\x9a\x1e"), definition of value binding ValueId(3): could not find func in module ModName("UserApp") with name FuncName("\'\x00\x00\x00\x04\x00\x00\x00\x94B\xe9\x05\x0em\x9a\x1e")', crates/compiler/gen_llvm/src/llvm/build.rs:5744:19
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

turning on backtrace also doesn't give me any useful info. Did I miss anything here?

view this post on Zulip Brendan Hansknecht (Dec 18 2023 at 17:19):

Not sure if it will be a fix at all, but try using Task.loop

view this post on Zulip Brendan Hansknecht (Dec 18 2023 at 17:20):

Currently there are definitely some bugs with recursive tasks and I think Task.loop tends to work around them.

view this post on Zulip Steven Chen (Dec 18 2023 at 17:34):

yeah Task.loop works. Surprised with the manual loop though. Seems like a known issue. Is this tracked already?

view this post on Zulip Anton (Dec 18 2023 at 17:37):

Yes, in #5701, it's hard to debug unfortunately.

view this post on Zulip Steven Chen (Dec 18 2023 at 17:43):

Thanks!

view this post on Zulip Notification Bot (Dec 18 2023 at 17:43):

Steven Chen has marked this topic as resolved.


Last updated: Jul 06 2025 at 12:14 UTC