I've been seeing quite a few fuzzing bugs with indented else; perhaps it's time to remove that?
For reference, that's when you do something like this:
x = |args|
if a == 0 then
foo
else
this_is_part_of_the_else!()
so_is_this!()
Technically speaking, I'm not sure the intended replacement (early-return) is ready - but it's also easy to migrate away from this automatically with the formatter.
What this would look like:
Thoughts?
If it's on another line, shouldn't it be indented from the else
?
I guess I don't really understand or have any experience with early return
It was introduced here: #ideas > "early returns" via formatter
Also see
The idea is/was that we can remove "rightward drift" of if statements, if we allow the else branch to be indented at the level of the outer scope - and that this is a simple syntactic transformation.
My understanding is that the intent is to replace that with early return statements
I have ideas on how to fix the bugs fuzzing is finding with this syntax, but doesn't seem worth implementing if we're just going to rip it out soon anyway
This makes sense to me
I find the hanging else
really confusing
processArgs = \args =>
if List.isEmpty args then
return Err NoArgs
# rest of body
Yeah, I much prefer early return
as well
I'm going to throw together a PR to remove it, but let's not merge until we get the final go-ahead :smiley:
(by "remove it", I just mean step (1), above)
Shouldn't be a breaking change at all
https://github.com/roc-lang/roc/pull/7536
I vote just remove it
And then implement else-less ifs
No one is using it
It was a stop gap that isn't useful on its own now that we have return
Anyone object?
yeah let's axe it :rip:
honestly this was one of the experiments that motivated adding return
in the first place
it revealed that the answer to the question "can we get a comparably nice experience with formatting instead of a new keyword?" was "no"
And now error handling is way better because of return
!
I'm fine with this (I didn't even realize this was allowed in the first place), good riddance!
Last updated: Jul 06 2025 at 12:14 UTC