Hi! I've been using roc for advent of code for a couple days now, I am very impressed with the language and its features, however I haven't been able to use dbg
correctly, sometimes it either panics the compiler or prints stuff that is not correct. For example, this code from the tutorial panics
app "hello"
packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.1.1/zAoiC9xtQPHywYk350_b7ust04BmWLW00sjb9ZPtSQk.tar.br"}
imports [pf.Stdout]
provides [main] to pf
total = addAndStringify {birds: 5, iguanas: 7}
main =
Stdout.line "There are \(total) animals."
addAndStringify = \counts ->
dbg counts
num1 = counts.birds
num2 = counts.iguanas
sum = num1 + num2
if sum == 0 then ""
else if sum < 0 then "negative"
else Num.toStr sum
It seems that I might not understand how dbg fully works, my current assumption is that dbg somehow "consumes" the value and then can not be used after. Any tips on how to use dbg effectivelly?
we did just merge some improvements to dbg
. How old is your roc compiler?
How old is your roc compiler?
@Andres Villegas you can check this with roc version
it is not that old: roc nightly pre-release, built from commit 234f9f5 on Fri Dec 9 12:57:48 UTC 2022
I am on apple Sillicon MacOS 13
I can check tomorrow if this reproduces on the latest main
I should be able to do this tomorrow @Andres Villegas, I spent all day trying to fix an issue with my graphics drivers and re-installing my OS.
This also reproduces on Ubuntu 20.04 with today's nightly, I'll make an issue for it.
Thanks Anton, I don't use Zulip that much, sorry for the delay answering. I really apreciate your help.
Last updated: Jul 06 2025 at 12:14 UTC