[swift-users] Expression was too complex to be solved in reasonable time

Ireland, Evan evan.ireland at sap.com
Wed Oct 25 14:33:29 CDT 2017

Nate wrote:

> I have four bool values: topLeft, bottomLeft, topRight, and bottomRight


> the following line throws an error:

> let value = Int(topLeft.hashValue) | Int(topRight.hashValue) << 1 |

> Int(bottomLeft.hashValue) << 2 | Int(bottomRight.hashValue) << 3


> "Expression was too complex to be solved in reasonable time; consider

> breaking up the expression into distinct sub-expressions."

It's really unfortunate how operator overloading and "integer literals" don't play nicely together any more.

Rather than break up the expression, you can change each integer literal to specify its type, e.g. change:



    (3 as Int)

That way you can have the expression structure that you want rather than having to break expressions into separate statements (which is particularly important if you want to take advantage of short-circuit logical operators such as && and ||).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20171025/dcc36054/attachment.html>

More information about the swift-users mailing list