Open stevage opened 5 years ago
@stevage Can you describe your use case for wanting this behavior with the match
operator? It can be supported, but it is not clear to me what the value of this would be, compared to the complexity of providing such a no-branches fallback.
No use case here. If it's any harder to implement than changing a 4 to a 2, it's probably not worth it.
There was an attempt at fixing this at #6964, which we punted on — see discussion on the reasons there.
@asheemmamoowala I actually have a usecase where I needed this. I'm generating a "match" from other data, and in one case that other data resulted in no cases. It was very surprising that this caused an error, because there was still the "fallback" value. Caused a bug in production.
The same probably applies to "case" and perhaps other things too.
@mourner That issue was describing a different usecase, where the last value was a label not a fallback value.
@mvirkkunen Ah yes, I have run into that situation as well. I think similar issues arise sometimes when you end up with an expression like ['any']
etc.
This wasn't valid as a match expression:
That is, a
match
where there is only the default value (everything else was temporarily commented out). It seems legitimate by analogy with: