8 Replies
      Latest reply on Apr 6, 2017 8:54 AM by John368
      Jens Level 3 Level 3 (230 points)

        Here's an example of an expression that the Swift compiler says is too complex to be solved in reasonable time (Xcode 7.0, OS X 10.10.5):

        let intBinaryOpsDict: [String : (Int, Int) -> Int] = [
            "add" : (+),
            "sub" : (-),
            "mul" : (*),
            "div" : (/)
        ]
        
        
        
        
        

         

        Commenting out one of the four dictionary elements will make it compile.

        So it can manage three, but inferring the specific type of four overloaded operators is too much, even though the specific type of the operators is right there in the explicitly declared type of the Dictionary, ie its Value type: (Int, Int) -> Int.

        ( 22810685 )

         

        Feel free to add other examples of such seemingly simple expressions for which the compiler will give the error message:

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