This PR adds support for constant patterns, that is patterns matching specific booleans, strings, numbers or the null value. This allows to write for exampe:
match {
"foo" => ...,
"foo/bar" => ...,
other => ...
}
Or
match {
{enabled = true, ..rest} => code_path_when_enabled rest,
{enabled = false, ..} => 'Error "Is not enabled!",
}
For destructuring, the semantics is the same as for enum tags - which are actually constants as well, but were just supported as a side effect of supporting eneral enum patterns - : a constant pattern forces the value and works as an assertion.
This PR adds support for constant patterns, that is patterns matching specific booleans, strings, numbers or the null value. This allows to write for exampe:
Or
For destructuring, the semantics is the same as for enum tags - which are actually constants as well, but were just supported as a side effect of supporting eneral enum patterns - : a constant pattern forces the value and works as an assertion.