[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    

 Description   

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.

long.swift



 Comments   
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 Wed Jun 20 14:10:58 CDT 2018 using JIRA 7.3.4#73015-sha1:a262b3457b3605f12635df4b0a0c3dc71d631a1e.