Proposal: disallow bare return error union #2562
Labels
proposal
This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
One of the things I like about zig is the explicit control flow. But a slight confusion point arises because current semantics treats
return
andtry
as "equals":We can clearly tell there are 2 lines can error, but the third is ambiguous and requires digging into the
getUser
definition to confidently say it cannot error. If we disallow bare union returns, this must be converted toreturn try author.getUser();
which eliminates the guessing game.At a basic level, requiring an extra 4 characters feels a little silly, but I think the benefits can add up, especially in larger projects with many "tail call" errors.
I don't think this would affect any other language semantics.
The text was updated successfully, but these errors were encountered: