Consider the following toy code:
my $age-check = do given 18 {
when $_ > 18 { 'old enough' }
when $_ < 18 { 'too young' }
};
say "The user is $age-check" # OUTPUT: «The user is False»
This code contains a bug (not handling the case where the input is exactly 18) that results in a runtime error. Is there any way to catch this error at compile time by requiring the given block to exhaustively match? It seems like there should be a way to use a CHECK phaser or something similar to require the match to be exhaustive, but I'm not quite sure how I'd go about doing so.
(I know you could catch the bug earlier during runtime with a default case that throws an error, but that's not what I'm asking about. If Raku doesn't have a way to enforce exhaustive matches at compile time, that's not a big drawback to the language – but it can be a helpful feature to have.)