I've come across what I believe is a bug - or at least leaves much room for improvement.
I have code along the lines of:
func bar() -> [UInt8] {
return [ 0x00 ]
}
let foo: [UInt8] =
bar() +
bar() +
...
bar()
Given that the types are very explicit I didn't think it should be too hard to figure out the type information. Yet if this list becomes longer compilation never finishes - at least not a reasonable time. I always aborted. Also because the CPU and memory usage was crazy.
Another similar example should also demonstrate the problem:
While this compiles fine
let foo: [UInt8] =
[1] +
[2]
this does not
let foo: [UInt8] =
[1] +
[2] +
[3] +
[4] +
[5] +
[6] +
[7]
Switching to
var foo: [UInt8] = []
foo += bar()
foo += bar()
foo += bar()
foo += bar()
foo += bar()
is a really ugly workaround.
I am using
$ swift -v
Apple Swift version 4.0.3 (swiftlang-900.0.74.1 clang-900.0.39.2)
Target: x86_64-apple-macosx10.9
/Applications/Xcode.app/Contents/Developer/usr/bin/lldb "--repl=-enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -color-diagnostics"
Any thoughts on this?