Skip to content

[SR-10130] Type-check time regression #52532

@zienag

Description

@zienag
Previous ID SR-10130
Radar rdar://problem/48992848
Original Reporter @zienag
Type Bug
Environment
$ swift --version
Apple Swift version 5.0 (swiftlang-1001.0.69 clang-1001.0.45.2)
Target: x86_64-apple-darwin18.2.0

and

$ swift --version
Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)
Target: x86_64-apple-darwin18.2.0
Additional Detail from JIRA
Votes 3
Component/s Compiler
Labels Bug
Assignee @xedin
Priority Medium

md5: f9286493c3d7b5a218f3e92d60bde680

relates to:

  • SR-10461 Unable to type check expression, Xcode 10.2 regression

Issue Description:

The following code compiles successfully in swift 4.2, and fails in swift 5:

let itemsPerRow = 10
let size: CGFloat = 20
let margin: CGFloat = 10
let foo = (0..<100)
  .map { (row: CGFloat($0 / itemsPerRow), col: CGFloat($0 % itemsPerRow)) }
  .map {
    CGRect(x: $0.col * (size + margin) + margin,
           y: $0.row * (size + margin) + margin,
           width: size,
           height: size)
}
print(foo)

Error:

test/main.swift:24:4: error: the compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
  .map {
~~~^~~~~

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itself

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions