Here's one,
import SQLite
var r:[[Any]] = []
do {
if let stmt = try local.db?.prepare(q) {
r = Array(stmt)
}
else {
print("woe in sql?")
}
}
catch { return [] }
the call
r = Array(stmt)
gives Expression implicitly coerced from 'Binding?' to Any.
And indeed, I do not know how to Provide a default value to avoid this warning, Force-unwrap the value to avoid this warning, or even Explicitly cast to Any with 'as Any' to silence this warning. :O
Here's a self-contained example that reproduces the same warning:
struct Binding {}
struct Statement : IteratorProtocol, Sequence {
func next() -> [Binding?]? {
return nil
}
}
let stmt = Statement()
let r: [[Any]]
r = Array(stmt) // warning: Expression implicitly coerced from 'Binding?' to Any.
Related interesting question:
Why does the compiler ...
... appear to not know the line number, with problems like this? And indeed: why does the warning only arise once you compile?
Most warnings appear right there in the IDE as you're typing, before compilation.
This warning would appear to (a) only be known during compiling and (b) the compiler doesn't know the line number.
How so? What's the difference?