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-2259] New "expression was too complex" error in swiftlang-800.0.41.2 (Xcode 8 beta 4) #44866

Closed
lorentey opened this issue Aug 2, 2016 · 2 comments

Comments

@lorentey
Copy link
Member

@lorentey lorentey commented Aug 2, 2016

Previous ID SR-2259
Radar None
Original Reporter @lorentey
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Apple Swift version 3.0 (swiftlang-800.0.41.2 clang-800.0.36)
Target: x86_64-apple-macosx10.9

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 3.0Regression, TypeChecker
Assignee @lorentey
Priority Medium

md5: cab3005164fef8464fdf85648ba7fdfa

Issue Description:

The code below (also attached) compiles without errors under Swift 2.x and Swift 3.0 betas before the latest, beta 4:

struct Foo {
  #if swift(>=3)
    init<S: Sequence>(elements: S) {}
  #else 
    init<S: SequenceType>(elements: S) {}
  #endif
}

func test() {
  let c = 26
  let foo = Foo(elements: (0 ... 2 * c + 1).map { ($0 & ~1, String($0)) }) 
  print(foo)
}

However, in the Swift 3.0 compiler that's included in Xcode 8 beta 4, line 11 produces the following error:

complex-expression.swift:11:13: error: expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions
  let foo = Foo(elements: (0 ... 2 * c + 1).map { ($0 & ~1, String($0)) }) 
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Extracting the upper bound of the closed range expression into a separate variable works around the issue.

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Aug 16, 2016

Comment by Abdullah Abanmi (JIRA)

resolved in xcode 8b6 w/ swift 3

@rudkx
Copy link
Member

@rudkx rudkx commented Aug 26, 2016

Should be fixed by 5a8950a

Please reactivate if you find that not to be the case.

@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
Projects
None yet
Development

No branches or pull requests

3 participants