Hey all, I ran into this issue myself while doing library dev, and thought I could give a simpler reproduction. I've done so in this comment, with the gist below:
main =
color = Blue
when color is # crash assuming Red is valid
Red -> Stdout.line "The color is red."
I propose two possible solutions, with the second being better IMO. In short, we should tell users to provide more when
arms (or a _ ->
arm) if we can't find enum variants during exhaustiveness checking. I'd like to pick this up if no one has any objections. I understand if the team would rather someone with more hands-on Roc compiler experience take the issue, no feelings hurt.
Also, my first try at reducing the issue in this comment isn't correct. I first considered deleting it, but I don't know the team's position on saving history. Is it better to do what I did where I leave comments at the top and bottom saying to DISREGARD, or should I just edit/delete the comment if no one is quoting it or anything?
Hi @Sam Mohr,
The second solution sounds good, you're welcome to take a crack at it :)
I first considered deleting it, but I don't know the team's position on saving history.
I have collapsed/hidden that comment.
Thanks for getting a better example and for being willing to give fixing it a go! I think your solution sounds good to me and is what I would have expected to happen.
I'm definitely surprised this breaks. I thought it used to work, but maybe I'm just thinking of a similar variant.
As an extra note, this probably should have a chain of 2 errors. First it should say that Blue
is missing. Either and explicit blue or an _ ->
is needed
Once the user adds in that branch. It should error saying that Red
is not a possible variant and should be removed.
I guess it could technically even give both errors at the same time.
Brendan Hansknecht said:
Once the user adds in that branch. It should error saying that
Red
is not a possible variant and should be removed.
This is already shown when the user adds the Blue match arm, luckily for us. If my fixing the issue causes it to show both at once, that'll be lucky. It'd probably be better to have both errors shown yes
Last updated: Jul 06 2025 at 12:14 UTC