binary operator '??' cannot be applied to functions?

in playground:


func f1() {
    return
}
var f2:(()->())?

let f3 = f2 ?? f1


give output:

error: binary operator '??' cannot be applied to operands of type '(() -> ())?' and '() -> ()'


what went wrong?

Replies

An interesting exploration of the behavior of the current Swift.


This is as interesting:

var f = f1
let f3 = f2 ?? f

Works as expected.


Also this:

let f = f1
let f3 = f2 ?? f

Shows the same error.


Maybe what is wrong is the current Swift.

Thanks for the confirmation. radar filed.

This is a known bug in the compiler handling autoclosure around functions.


-Chris