Closed fwgreen closed 4 days ago
Thanks for reporting this @fwgreen!
In case it may help, this is a workaround:
dbg List.len results
end = Utc.toMillisSinceEpoch Utc.now!
dbg end - start
Minimal reproduction for future debugging:
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.10.0/vNe6s9hWzoTZtFmNkvEICPErI9ptji_ySjicO6CkucY.tar.br" }
import pf.Stdout
import pf.Task
import pf.Utc
main =
dbg Utc.now!
Stdout.line! "Done"
The corresponding place in compiler:
It was probably done to not mess with control flow, but I can't say precisely. @lukewilliamboswell any insights? Should we add better logging here or make dbg work with the bang?
It's an error. Dbg shouldn't be used with a bang suffix.
We should improve the error message. I think we just left it as something basic like MalformedSuffix and haven't added any actual error reports yet.
Dbg shouldn't be used with a bang suffix.
Can you expand on that @lukewilliamboswell? It seems like we can make it work and I think it's a feature users would like to have.
I think I need to defer to @rtfeldman here. It may be possible to unwrap it, but I think it also may be a deliberate design choice.
For example
# this could in theory
main =
dbg Utc.now!
Stdout.line! "Done"
# unwrap to
main =
Task.await Utc.now \answer ->
dbg answer
Stdout.line! "Done"
But do we want this?
Yeah, as I mentioned, it leads to control flow change. I think it makes sense that dbg
is expected to be transparent for control flow. But dbg
with bang requires the change only to make dbg
work.
Upd. However, the alternative is to introduce the await manually
But do we want this?
I think we want it! 👍
Ok, I'll add the fix
@rtfeldman I'd assume expect
shouldn't support bangs inside? My intuition is if you await something for expect, you intend to use it later. But maybe there are special cases?
roc nightly pre-release, built from commit d47a073634e on Tue Jun 25 09:12:30 UTC 2024
on macOs 14.5