Re:The Swift compiler is slow due to how types are inferred
by floxy on Wednesday June 12, 2024 @08:03PM
(#40664513)
I found an online Swift Playground, and here is a smaller test case that produces the "unable to type-check this expression in reasonable time" message:
...if you reduce it even further to:
...the error message is:
...it still falls down on with the "reasonable time" error on this tiny example, even if you fully specify the types:
...is that pointing to a problem with type-checking or overload resolution more than type inference? Is there a way in Swift to annotate the types of sub-expressions in-line, so you could try something like:
[ Parent
| on HN ]
Re:The Swift compiler is slow due to how types are inferred
by amomchilov on Thursday June 13, 2024 @05:36AM
(#40667613)
`print((a + b + c) as String + n + d + e)`
(Iām not sure of the precedence, that might need another pair of parens)
Re:The Swift compiler is slow due to how types are inferred
by floxy on Thursday June 13, 2024 @12:05PM
(#40671364)
Interesting. This:
let a:String = "a" as String
let b:String = "b" as String
let c:String = "c" as String
let d:String = "d" as String
let e:String = "e" as String
let n:Int = 11 as Int
print((a + b + c) + n + d + e)
...has the long timeout, while: let a:String = "a" as String
let b:String = "b" as String
let c:String = "c" as String
let d:String = "d" as String
let e:String = "e" as String
let n:Int = 11 as Int
print((a + b + c) as String + n + d + e)
...fails pretty much instantaneously.
Re:The Swift compiler is slow due to how types are inferred
by amomchilov on Thursday June 13, 2024 @06:14AM
(#40667830)
The slow-down here isn't just from picking the correct `+` overloads, but also the various types that `"a"` could be (e.g. `String`, `Substring`, `Character`, or something like a `SQLQuery` type, depending on what libraries you have imported)