While working on the IDE, I noticed that it's really inconvenient to not be able to write:
switch (maybeFooOrBar)
case (is Foo) { … }
case (is Bar { … }
else if (something) { … }
Previously the language forced me to write:
switch (maybeFooOrBar)
case (is Foo) { … }
case (is Bar { … }
else {
if (something) { … }
}
This is a bit irregular, since in at most other contexts, you can write else if where else is supported.
So I made an adjustment to the parser to support this.
I had a tiny doubt about this because it seems like this defeats the "exhaustiveness" of the switch, but I don't think that objection is correct, since:
The rule is that when you write an else, you're indicating that you know the switch is inexhaustive ... and this complies with that.
This objection confuses exhaustiveness analysis with definite return/assignment checking, which is actually a different thing, and which is not at all broken by this change.
If anyone objects to this change, please reopen this issue.
While working on the IDE, I noticed that it's really inconvenient to not be able to write:
Previously the language forced me to write:
This is a bit irregular, since in at most other contexts, you can write
else if
whereelse
is supported.So I made an adjustment to the parser to support this.
I had a tiny doubt about this because it seems like this defeats the "exhaustiveness" of the
switch
, but I don't think that objection is correct, since:else
, you're indicating that you know theswitch
is inexhaustive ... and this complies with that.If anyone objects to this change, please reopen this issue.