Stream: beginners

Topic: ✔ Dbg broken in package land


view this post on Zulip Ian McLerran (Jan 29 2025 at 16:41):

Is it a known issue that dbg statements do not work in package land?

Using a dbg statement anywhere in package code which is called from an app will cause a compiler panic:

thread '<unnamed>' panicked at crates/compiler/mono/src/ir.rs:6007:10:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:647:5
   1: core::panicking::panic_fmt
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/panicking.rs:72:14
   2: core::panicking::panic
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/panicking.rs:144:5
   3: core::option::unwrap_failed
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/option.rs:1978:5
   4: roc_mono::ir::compile_dbg
   5: roc_mono::ir::from_can
   6: roc_mono::ir::from_can_let
   7: roc_mono::ir::from_can
   8: roc_mono::ir::specialize_variable
   9: roc_mono::ir::specialize_external_help
  10: roc_mono::ir::specialize_all
  11: roc_load_internal::file::run_task
  12: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

view this post on Zulip Ian McLerran (Jan 29 2025 at 16:41):

Here is a min repro:

app [main!] {
    cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.19.0/Hj-J_zxz7V9YurCSTFcFdu6cQJie4guzsPMUi5kBYUk.tar.br",
    ex: "https://github.com/imclerran/roc-ex/releases/download/v0.1.1/qQKhuWXAnzq7xFahZlEhpXiV6yt0vEsYXkVQgznhxaM.tar.br"
}

import cli.Stdout
import ex.Example

main! = |_args|
    str = Num.to_str(Example.debug)
    Stdout.line!(str)

view this post on Zulip Ian McLerran (Jan 29 2025 at 16:42):

Note that Example.roc in the roc-ex package looks like:

module [value, debug]

value = 1

debug = dbg 1

view this post on Zulip Anton (Jan 29 2025 at 16:57):

This is #7295 I've upgraded it to medium priority

view this post on Zulip Notification Bot (Jan 29 2025 at 17:00):

Ian McLerran has marked this topic as resolved.

view this post on Zulip Ian McLerran (Jan 29 2025 at 17:01):

Thanks, Anton! Figured this must be a known issue.


Last updated: Jul 06 2025 at 12:14 UTC