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-12670] Compiler crash with certain generic constraints #55114

Closed
NevinBR opened this issue Apr 25, 2020 · 5 comments
Closed

[SR-12670] Compiler crash with certain generic constraints #55114

NevinBR opened this issue Apr 25, 2020 · 5 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@NevinBR
Copy link
Contributor

NevinBR commented Apr 25, 2020

Previous ID SR-12670
Radar rdar://problem/62895018
Original Reporter @NevinBR
Type Bug
Status Resolved
Resolution Done
Environment

Swift 5.1.3

Xcode 11.3.1

MacOS 10.14.6

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

md5: 2f1f35b69d7ff155d7ed2e7ec91fe52c

Issue Description:

The following code crashes the compiler (specifically, swift and SourceKitService both unexpectedly quit) in Xcode 11.3.1 running Swift 5.1.3:

protocol P { associatedtype A }
enum E<A>: P {}

struct S<G: P> where G.A: Numeric {
  typealias X = G.A
  init<T>(_ x: X) where G == E<T> {}
}

func foo() { S(1) }

Note that commenting out the last line (the foo() function) will let the rest of the code compile successfully.

The initializer call S(1) seems plausibly valid since Int does conform to Numeric.

Furthermore, even if the type being initialized is fully specified as S<E<Int>>(1), it will still crash the compiler.

@dabrahams
Copy link
Collaborator

Crash reproduces in Swift 5.2.2 but not the 2020-04-17 release of the S4TF toolchain, which has merged apple/swift:master in the past week.

@beccadax
Copy link
Contributor

beccadax commented May 5, 2020

@swift-ci create

@xymus
Copy link
Contributor

xymus commented May 7, 2020

This should be fixed in recent compilers. @NevinBR can you try with Xcode 11.5 beta 2 or a development snapshot at https://swift.org/download/#snapshots and confirm if this issue is fixed?

@swift-ci
Copy link
Collaborator

swift-ci commented May 8, 2020

Comment by Daniel Sweeney (JIRA)

I just built this (the code snippet above) without a crash on the 05-04 Swift 5.3 toolchain and the 05-05 Swift Development toolchain.

It crashes the compiler and SourceKit on the Xcode 11.4.1 Toolchain though.

So it looks like this is OK in the development snapshots.

@xymus
Copy link
Contributor

xymus commented Jun 25, 2020

Thank you for everyone who confirmed this already, but I can add that the code snippet doesn't reproduce the crash in the Xcode 12 beta either.

Marking this as resolved. @NevinBR, please reopen it if you see this problem again.

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

No branches or pull requests

5 participants