Stream: beginners

Topic: dbg broken in new compiler?


view this post on Zulip Johannes Maas (Dec 09 2025 at 07:52):

I'm trying out the new compiler on AoC and my dbg statement has no effect in the terminal.

My code is this:

app [main!] { pf: platform "https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/0.4/6XA8JLWhmG1FSgb8GxPjBs9cGrtRqopohR3KAHYo722z.tar.zst" }

import pf.Stdout
import pf.Stdin

main! = |_args| {
    parsed = parse_input(input)
    dbg "dbg"
    dbg parsed
    Stdout.line!("stdout")
    Ok({})
}

parse_input = |_| {
    [Left(21), Right(37)]
}

input = "R33\nL22\n..."

Running roc main.roc, this is only printing "stdout", no "dbg" or other stuff...

I want to report this just for the case that it is inadvertently broken. I will manage without it and it's fine if it is not yet implemented. :)

view this post on Zulip Matthieu Pizenberg (Dec 09 2025 at 08:14):

not sure about dbg, but since you are trying the new compiler, beware that there are still bugs that are not easy to circumvent to solve AoC puzzles. Currently, my AoC day 1 solution is still leaking memory, and my day2 is still facing panics or other crashes. There has been a lot of progress in bug fixing but still not there yet.

view this post on Zulip Johannes Maas (Dec 09 2025 at 08:15):

Yep, I'm aware that the compiler is fresh. Thanks for the heads up! :)

view this post on Zulip Luke Boswell (Dec 09 2025 at 08:18):

It was working... but I think we may have broken it recently.

view this post on Zulip Luke Boswell (Dec 09 2025 at 08:18):

If you make a GH Issue that would help track it. Do you know if it's all dbg statements?

view this post on Zulip Johannes Maas (Dec 09 2025 at 08:19):

I will make a GH issue with all information I have. :)

view this post on Zulip Luke Boswell (Dec 09 2025 at 08:21):

Oh I think I know what the issue here specifically is...

view this post on Zulip Luke Boswell (Dec 09 2025 at 08:22):

/// Roc debug function
fn rocDbgFn(roc_dbg: *const builtins.host_abi.RocDbg, env: *anyopaque) callconv(.c) void {
    _ = env;
    const message = roc_dbg.utf8_bytes[0..roc_dbg.len];
    std.log.debug("\x1b[33mRoc dbg:\x1b[0m {s}", .{message});
}

view this post on Zulip Luke Boswell (Dec 09 2025 at 08:22):

This is from the platform... and we print using std.log.debug

view this post on Zulip Luke Boswell (Dec 09 2025 at 08:22):

When I built a release of the platform I used -Doptimize=ReleaseSafe so I bet that is a no-op when using that platform from a URL release

view this post on Zulip Luke Boswell (Dec 09 2025 at 08:23):

That should probably be using stderr instead, and have a global so it exits with a non-zero exit code I think.

view this post on Zulip Luke Boswell (Dec 09 2025 at 08:24):

So I don't think this is a "bug" in Roc but in my zig platform template.

view this post on Zulip Luke Boswell (Dec 09 2025 at 08:25):

Yeah so with this test program using the fx test platform

app [main!] { pf: platform "./platform/main.roc" }

import pf.Stdout
import pf.Stdin

main! = || {
    parsed = parse_input(input)
    dbg "dbg"
    dbg parsed
    Stdout.line!("stdout")
}

parse_input = |_| {
    [Left(21), Right(37)]
}

input = "R33\nL22\n..."
$ roc test/fx/test_app.roc
ROC DBG: "dbg"
ROC DBG: [<tag_union variant=0>, <tag_union variant=1>]
stdout

view this post on Zulip Johannes Maas (Dec 09 2025 at 08:26):

Thanks! Do you want me to create an issue on your platform repo? (I have created one on the Roc repo which I will close.)

view this post on Zulip Luke Boswell (Dec 09 2025 at 08:26):

Interestingly though... that <tag_union variant=0> looks like a bug to me, that should print the tag I would assume

view this post on Zulip Johannes Maas (Dec 09 2025 at 08:28):

GH issue: https://github.com/lukewilliamboswell/roc-platform-template-zig/issues/18

view this post on Zulip Luke Boswell (Dec 09 2025 at 08:30):

If I can fix my issues with the roc build PR I need to make a new release of the platform anyway as that is a breaking change for the platforms, they now require a "targets" section in the platform header

view this post on Zulip Anton (Dec 09 2025 at 09:36):

@Luke Boswell so you know, you can now make a release of roc-platform-template-zig by clicking the "Run workflow" button here.

view this post on Zulip Luke Boswell (Dec 09 2025 at 10:46):

Thank you Anton, I hadn't noticed that

view this post on Zulip Luke Boswell (Dec 09 2025 at 10:51):

The above issue is fixed in commit f3bb846a74cbcbf4f80252e85252d0df79effcfb should be in the next release


Last updated: Dec 21 2025 at 12:15 UTC