Experimenting with @autoclosure with variatic parameters. With that qualifier there, compiler faults. Comment just "@autoclosure" out, then it compiles just fine. Code:
fileprivate func LOG(_ flag: Int, _ items: @autoclosure Any..., separator: String = " ", terminator: String = "\n") {
if flag > 0 {
// Commenting these out has no effect
let str = items.map{String(describing: $0)}.joined(separator: separator)
print(str, terminator: terminator)
}
}
class ViewController: UIViewController {
var notificationTimer = DispatchWorkItem(block: {} )
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
LOG(1, "Does it get called?", 5, 7, expensiveFunc()) // Segmentation fault
//LOG(0, "Does it get called?", expensiveFunc()) // OK
}
func expensiveFunc() -> String {
print("CALLED")
return "EXPENSIVE!!!"
}
}
Fault:
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: compile command failed due to signal 11 (use -v to see invocation)
Xcode 11.2, Mac -> latest Catalina, Target iPhone 13.2
Where should I enter the bug report? Also, is there a workaround for this?
Entered a bug on Swift.org, it was accepted, and as a result two other bugs were found :-)