[swift-evolution] Pitch: disallow `()` from Switch statement case satisfaction

Xiaodi Wu xiaodi.wu at gmail.com
Tue Oct 11 13:54:40 CDT 2016


Well, unless I'm mistaken, `()` here is a value. I can replace it with `3`
and the compiler emits a warning about unused results. I'm guessing that
since () is a value of type Void, the warning about unused results isn't
triggered.
While it's true that `Void` causes an error, I can write `Void()` instead
and everything compiles just fine, which is what the `()` is doing too.
Seems fine to me?


On Tue, Oct 11, 2016 at 1:43 PM, Erica Sadun via swift-evolution <
swift-evolution at swift.org> wrote:

> I thought this was long gone but today I found out it is still legal:
>
> switch i {
> case 4 ... 6: ()
> case 3: print("Here")
> default: break
> }
>
> Is there a motivating factor for keeping this in the language? The
> compiler picks up on Void and emits an error. You'd think () would produce
> the same results but it doesn't.
>
> -- Erica
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161011/645bed3d/attachment.html>


More information about the swift-evolution mailing list