Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-305] Simple, legit literal takes exponentially growing compile time. #42927

Closed
dduan opened this issue Dec 18, 2015 · 4 comments
Closed

[SR-305] Simple, legit literal takes exponentially growing compile time. #42927

dduan opened this issue Dec 18, 2015 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@dduan
Copy link
Collaborator

dduan commented Dec 18, 2015

Previous ID SR-305
Radar None
Original Reporter @dduan
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 6
Component/s Compiler
Labels Bug, TypeChecker
Assignee @jopamer
Priority Medium

md5: 671f0ac06627b6519c1b4f035d41c57c

Issue 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

@belkadan
Copy link
Contributor

Dictionary of dictionaries of dictionaries of string-string mappings.

@modocache
Copy link
Mannequin

modocache mannequin commented Apr 26, 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?

@belkadan
Copy link
Contributor

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

@jopamer
Copy link
Contributor

jopamer commented Apr 27, 2016

Fixed in master with 2cdd7d6.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants