Skip to content

[SR-10253] Type checker takes a very long time for tuple array #52653

@tkrajacic

Description

@tkrajacic
Previous ID SR-10253
Radar None
Original Reporter @tkrajacic
Type Bug

Attachment: Download

Environment

Xcode 10.2, macOS 10.14.4 (18E226), Swift 5

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Performance, TypeChecker
Assignee None
Priority Medium

md5: 837d8a515bbce96883d9d71a5c26b581

Issue Description:

This code takes between 15 and 25❗ seconds to type-check in the production app.

lazy var data: [(timespan: TimeInterval, caption: String)] = {
        
    return [
            (timespan: 0, caption: L10n.atDueDate),
            (timespan: 5 * kMinute, caption: L10n.xMinutesBefore(5)),
            (timespan: 15 * kMinute, caption: L10n.xMinutesBefore(15)),
            (timespan: 30 * kMinute, caption: L10n.xMinutesBefore(30)),
            (timespan: kHour, caption: L10n.oneHourBefore),
            (timespan: 2 * kHour, caption: L10n.xHoursBefore(2)),
            (timespan: kDay, caption: L10n.oneDayBefore),
            (timespan: 2 * kDay, caption: L10n.xDaysBefore(2)),
            (timespan: 7 * kDay, caption: L10n.oneWeekBefore),
    ]
}()

A simplified test-project is attached.

Of course it is easy to mitigate by just using a simple struct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfperformancetype checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions