Optional Unwrap case pattern

swift
silver
(Dante Broggi) #1

IDE: Visual Studio X/Fire
Version: _ 10.0.0.2399 (develop)_
Target (If relevant): OSX
Description:
(A) Swift (since 1.0 IIRC) allows a postfix “?” in a pattern for optionals to match only if the optional is non-nil, and enable further matching on the contained value.

(B) Additionally, the error message seems to be missing the (offending) character “?”.
Expected Behavior:
Part A:
Compiles.
Part B:
“E: comma or closing parenthesis expected, got “?” [<file (<line>)]”
Actual Behavior:
“E: comma or closing parenthesis expected, got [<file (<line>)]”
Steps:

enum F {
    case o(String?)
}
let f = F.o("foo")
switch f {
    case .o(let ov?):
    //            ^ Error Here
    // use ov: String
    case .o(nil):
        break
}
(RemObjects) #2

Thanks, logged as bugs://82586

(RemObjects) #3

bugs://82586 got closed with status fixed.