Skip to content

Serious type checking regression in Swift 5.8. #65765

Open
@mluisbrown

Description

@mluisbrown

Description
There appears to be a serious regression in the type checker for Swift 5.8 (compared to Swift 5.7). In the repro project I created, successive chaining of calls to a result builder modifier cause an exponential increase in compile types, reaching a point where the compiler gives up with Unable to type check the expression in reasonable time. In Swift 5.7 there was no such issue and successive chaining of the modifier didn't cause any significant increase in compile time.

Steps to reproduce

  1. Clone the Swift Package at https://github.com/mluisbrown/swift5.8-typechecker-regression.
  2. Try to build the package (for an iOS destination) using Xcode 14.3

Expected behavior
The project should build in reasonable time.

Using Xcode 14.3 the project does not build. Using Xcode 14.2 it builds without issue. There are further details in the README of the project and source code comments detailing how to demonstrate the exponential increase in compile time for each additional chaining of the .onChange modifier.

Environment

  • Swift compiler version info swift-driver version: 1.75.2 Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100), Target: arm64-apple-macosx13.0
  • Xcode version info Xcode 14.3, Build version 14E222b
  • Deployment target: iOS 16.4

As mentioned above, the issue did not exist in Xcode 14.2 and Swift 5.7 and is new to Swift 5.8.

As mentioned in the demo project: the demo uses the Swift Composable Architecture in order to demonstrated the problem. This is merely as it was how I discovered the problem and therefore was the easiest way for me to provide a repro project. I am pretty sure that the issue is not related to TCA, it just happened to be the easiest way to demonstrate it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.closuresFeature: closurescompilerThe Swift compiler itselfperformanceresult buildersFeature: Result buildersswift 5.8type checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions