unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.8k stars 271 forks source link

Support pattern matching on empty types #5298

Closed sellout closed 2 months ago

sellout commented 2 months ago

Overview

Previously, match and cases expressions needed to have at least one pattern to match on. This allows them to work with zero patterns, which is useful for matching on empty types.

Since EmptyMatch is no longer a failure case, errors that previously said “I expected some patterns after a match / with or cases but I didn't find any,” now say “Pattern match doesn't cover all possible cases”.

Fixes #4731.

Test coverage

There is a new transcript that covers the new cases. The existing error-messages transcript captures the change in error message with empty cases that are applied to non-empty types.