On Aug 29, 2015, at 13:05 , Gavin Eadie <ga...@umich.edu> wrote: > > I’ve been using Swift and moving some Obj-C code over to it, but I’m > concerned that it thinks this is “too complex to be solved in reasonable > time”: > > import Foundation > let y = 1.0 * sin(1.0) + 1.0 * sin(1.0) + 1.0 * sin(1.0) > > The above is simplified from the original (original didn’t have constants > under the sin function).
I think you can assume that the error message is in effect a secondary error. The expression complexity isn’t the issue, but rather the (internal) path Swift follows to compile it. Still, there is quite a bit of complexity hidden behind the scenes, since your constants are convertible to at least 3 different types (Double, Float and CGFloat) and there are two variants of ‘sin’ (one that takes a Float, and one that takes a Double). The tree of possibilities is not entirely trivial, so it’s probably hitting some internal limit that seems otherwise reasonable. (Simplistically, there are at least 3 * 2 *3 * 3 * 2 * 3 * 3 * 2 * 3 different type analyses to decide between.) Interestingly, the following compiles without error: > let y = 1 * sin(1.0) + 1 * sin(1.0) + 1 * sin(1.0) Also, in: > let one = 1.0 > let y = 1.0 * sin(one) + 1.0 * sin(one) + 1.0 * sin(one) > let z = one * sin(1.0) + one * sin(1.0) + one * sin(1.0) can you guess which of the last 2 lines doesn’t compile? I also occasionally get the same “too complex to be solved in reasonable time” error for expressions that don’t terribly complicated, but I don’t see there’s much you can do about it except to break up the expression, until the compiler is fixed/improved. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com