Re: [External] : Re: case null / null pattern (v2)

2022-04-21 Thread Brian Goetz
"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

Re: case null / null pattern (v2)

2022-04-21 Thread forax
> 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

Re: case null / null pattern (v2)

2022-04-19 Thread Brian Goetz
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

case null / null pattern (v2)

2022-04-18 Thread Remi Forax
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