TIL that Roc does not short-circuit on boolean operations. I am surprised I only hit this now :sweat_smile:
For context, the following program is a minimization of what I was trying to do. It crashes because of underflow:
app [main] { pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.17.0/lZFLstMUCUvd5bjnnpYromZJXkQUrdhbva4xdBInicE.tar.br" }
main =
idx = 0u64
_ = idx >= 3 && idx - 1 != 0
Task.ok {}
This was just brought up in the operator desugaring discussion. We plan to desugar a && b
to if a then b else False
and a || b
to if a then True else b
to implement short circuiting.
I don't see an issue for it on GitHub, we should make a few of those once we move towards implementing static dispatch
I'm so glad you hit this before me! How surprising! I don't think I've used a language without short circuiting in a _long_ time
Seems like something you'd want to wait to transform until IR
Last updated: Jul 05 2025 at 12:14 UTC