I can't think of how often I forgot the calling parens when initializing a variable through a closure.
Consider the following snippet:
static let q: OperationQueue = {
let q = OperationQueue()
q.name = "dev.cornucopia.core.LogFile.sharedBackgroundQueue"
q.qualityOfService = .background
q.maxConcurrentOperationCount = 1
return q
}
The compiler rightly prompts me with:
Cannot convert value of type '() -> _' to specified type 'OperationQueue'
Unable to infer complex closure return type; add explicit type to disambiguate
Insert ' () -> <#Result#> in '
Unfortunately the FIXME is not leading to a significant improvement.
I wonder whether the compiler could infer that what we're actually trying to do here and suggest a better fix? Like… Did you mean to call the closure? Insert ().
If this is possible, I'm happy to open an issue, but I'm not sure whether the compiler has enough information at this point, so I figured I'd better ask first.