[SR-305] Simple, legit literal takes exponentially growing compile time. Created: 18 Dec 2015  Updated: 26 Apr 2016  Resolved: 26 Apr 2016

Status: Resolved
Project: Swift
Component/s: Compiler

Type: Bug Priority: Medium
Reporter: Daniel Duan Assignee: Joe Pamer
Resolution: Done Votes: 6
Labels: TypeChecker

Attachments: File long.swift    


Run swiftc -dump-ast on this file, the compilation will never finish. Removing values gradually from the array and you'll notice that the shorter the expression, the less time it takes.


Comment by Jordan Rose [ 18 Dec 2015 ]

Dictionary of dictionaries of dictionaries of string-string mappings.

Comment by Brian Ivan Gesiak [ 26 Apr 2016 ]

This appears to be a pain point. From https://spin.atomicobject.com/2016/04/26/swift-long-compile-time/:

"Copy the above code into Xcode, press “build,” and go get a coffee. Come back in 12 hours. Yes, the above dictionary literal code takes at least 12 hours to compile. The compilation time grows roughly exponentially with each employee that is added."

A commenter on that article proposes speeding up the compilation by adding a type annotation:

let myCompany: [String: [String: [String: String]]]

Is this the best workaround right now?

Comment by Jordan Rose [ 26 Apr 2016 ]

Type annotations are always the first thing to reach for when an expression is taking a long time, yes.

Comment by Joe Pamer [ 26 Apr 2016 ]

Fixed in master with 2cdd7d64e.

Generated at Sun Dec 16 14:05:31 CST 2018 using Jira 7.13.0#713000-sha1:fbf406879436de2f3fb1cfa09c7fa556fb79615a.