"case Foo fooButNull" is equivalent to "case null" but with a binding
typed as Foo that's why i ask if it should even compile,
the compiler should ask for an explicit "case null".
It may be "equivalent" in our eyes, but the language doesn't currently
incorporate nullity into the type
> From: "Brian Goetz"
> To: "Remi Forax" , "amber-spec-experts"
>
> Sent: Tuesday, April 19, 2022 10:02:22 PM
> Subject: Re: case null / null pattern (v2)
> With the currently specified semantics, the second pattern is dead, because
> switche
With the currently specified semantics, the second pattern is dead,
because switches will only match null at the top level with a case
null. This was an accommodation to clarify that that the null-hostility
of switch is a property of switch, not patterns, and make it more clear
when switch
I've found a way to encode the null pattern if you have a record
record Foo(int x) { }
Foo foo = ...
return switch(foo) {
case Foo(int _) foo -> "i'm a foo not null here !";
case Foo fooButNull -> "i can be only null here !";
};
I wonder if allowing those two patterns, a record pattern and