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
}
It was fixed for trailing binding patterns, but apparently not for ‘literal’ patterns:
Version: 10.0.0.2457 (develop)
enum F {
case z
}
let f: F? = F.z
switch f { // E64 Type mismatch, cannot find operator to evaluate "F!" = "F!"
// W45 Switch does not cover all values
case .z?: // E287 Syntax error
// E1 colon expected, got "break"
// E65 Constant value expected
break // E287 Syntax error
case nil:
break
}