0

I've recently updated my Xcode and now receive the following error. The trouble is the code is imported from someone else and I don't fully understand it or understand how to break it up onto multiple lines for easier computing:

public protocol Expressible {
    var expression: Expression<Void> { get }
}
extension Expressible {
    // naïve compiler for statements that can’t be bound, e.g., CREATE TABLE
    // FIXME: use @testable and make internal
    public func asSQL() -> String {
        let expressed = expression
        var idx = 0
        return expressed.template.characters.reduce("") {
            template, character in
            return template + (character == "?" ? transcode(expressed.bindings[idx+=1]) : String(character))
        }
    }
}

Error is at the following line:

return expressed.template.characters.reduce("") {

Actual Error message is:

Expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions

Thank you.

Richard
  • 1,688
  • 3
  • 16
  • 21
  • 1
    You cannot do `expressed.bindings[idx+=1]` for a start. `+=` is a mutating operator that doesn't return anything – so you cannot use it to subscript, which is probably what's confusing the compiler. – Hamish May 30 '16 at 12:55
  • You are correct. I had changed the ++ to +=1. It must have confused things and generated the error. Thank you. – Richard May 30 '16 at 13:03

0 Answers0