Stream: beginners

Topic: How to clean?


view this post on Zulip Zeljko Nesic (Oct 19 2022 at 00:22):

Silly question, but I think I got in some weird state.

roc check file.roc have passed 0 errs, 0 warns, but roc run file.roc exploded on my face like a piñata.
Subsequent undos of the code make even roc check file.roc paniced.

So maybe it's worth debugging it, my question is, what would be rocs rm -rf ./node_modules equivalent?

For those interested below is log:

MacBook-Pro:examples popara$ ../target/debug/roc check cli/echo.roc

── UNUSED DEFINITION ──────────────────────────────────────────── cli/echo.roc ─

action is not used anywhere in your code.

37│      action =
         ^^^^^^

If you didn't intend on using action then remove it so future readers
of your code don't wonder why it is there.

────────────────────────────────────────────────────────────────────────────────

0 errors and 1 warning found in 395 ms.
MacBook-Pro:examples popara$ ../target/debug/roc check cli/echo.roc
0 errors and 0 warnings found in 320 ms.
MacBook-Pro:examples popara$ ../target/debug/roc run cli/echo.roc
🔨 Rebuilding platform...
thread 'main' panicked at 'Error in alias analysis: error in module ModName("UserApp"), function definition FuncName("\x01\x00\x00\x00\x16\x00\x00\x00\x02\\\xbd\x19\x94\x9bG\xe6"), definition of type binding TypeId(0): could not find named type in module ModName("UserApp") with name TypeName("\x17{\xd3\x8c\x03\xbeS\xb9")', crates/compiler/gen_llvm/src/llvm/build.rs:4504:23
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
MacBook-Pro:examples popara$ ../target/debug/roc dev cli/echo.roc
🔨 Rebuilding platform...
thread 'main' panicked at 'Error in alias analysis: error in module ModName("UserApp"), function definition FuncName("\x01\x00\x00\x00\x16\x00\x00\x00\x02\\\xbd\x19\x94\x9bG\xe6"), definition of type binding TypeId(0): could not find named type in module ModName("UserApp") with name TypeName("\x17{\xd3\x8c\x03\xbeS\xb9")', crates/compiler/gen_llvm/src/llvm/build.rs:4504:23
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
MacBook-Pro:examples popara$ ../target/debug/roc run cli/echo.roc
thread '<unnamed>' panicked at 'internal error: entered unreachable code: Expects { conditions: [Call((89, @371-373 AbilityMember(`Bool.isEq`, Some(SpecializationId(1)), 88), 90, 91), [(85, @362-370 Access { record_var: 82, ext_var: 84, field_var: 83, loc_expr: @362-370 Var(`#UserApp.nm`), field: 'cyber' }), (87, @374-376 Num(86, "42", I128([42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), AtLeastIntOrFloat { sign: NoDemand, width: I8 }))], BinOp(Equals))], regions: [@362-376], preceding_comment: [@355-355] }', crates/compiler/can/src/def.rs:2320:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
^C
MacBook-Pro:examples popara$ ../target/debug/roc check cli/echo.roc
thread '<unnamed>' panicked at 'internal error: entered unreachable code: Expects { conditions: [Call((89, @371-373 AbilityMember(`Bool.isEq`, Some(SpecializationId(1)), 88), 90, 91), [(85, @362-370 Access { record_var: 82, ext_var: 84, field_var: 83, loc_expr: @362-370 Var(`#UserApp.nm`), field: 'cyber' }), (87, @374-376 Num(86, "42", I128([42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), AtLeastIntOrFloat { sign: NoDemand, width: I8 }))], BinOp(Equals))], regions: [@362-376], preceding_comment: [@355-355] }', crates/compiler/can/src/def.rs:2320:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

^C
MacBook-Pro:examples popara$

view this post on Zulip Luke Boswell (Oct 19 2022 at 00:30):

It looks like you have triggered a compiler bug. This can happen when there are things in your .roc file that are not yet supported in the roc binary. Pretty sure there is nothing you need to clean up, just delete the generated executable file (or not as it will be overwritten anyway), and build again. Fro reference I prefer using roc dev which includes a typecheck like roc check. If you can narrow down your code to isolate the compiler bug, then you can create an issue for it.

view this post on Zulip Zeljko Nesic (Oct 19 2022 at 12:10):

Oh turned out to be even more trivial.
Compiler breaks when you write this

mainTask : Task ExitCode [] [Read [Stdin], Write [Stdout]]
mainTask =
    Task.forever (
        nm = { cyber : 42 , funk : "Yo" }
        msg = Vamos
        expect nm == nm # <<< THIS
        _ <- Task.await (Stdout.line "🗣 \(nm.funk) ! 👂👂👂")
        Task.loop nm (\model -> Task.map (tick  msg model) Step)
    )
    |> Program.exit 0

expect in Tasks == bazooka + piñata


Last updated: Jul 06 2025 at 12:14 UTC