[swift-users] Linux Swift: Strange bug found in a simple arithmetic

Lou Zell lzell11 at gmail.com
Wed Sep 7 09:44:47 CDT 2016


>
> It's certainly an interesting compiler issue, probably to do with the type
> analysis


I've for sure hit this before and now see with a little help to the
compiler the compile time drops dramatically:‚Äč

Float(abs(Double(0) - Double(0)))
repl.swift:50:1: error: expression was too complex to be solved in
reasonable time; consider breaking up the expression into distinct
sub-expressions

Float(abs(Double(0 as Int) - Double(0 as Int)))
// Compiles instantly!

It makes the code ugly though, so we're probably better-off busting it into
subexpressions like the error above states.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160907/e2a9312f/attachment.html>


More information about the swift-users mailing list