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-706] Swift 2.2 Regression: Using generic parameter as a generic argument in the same clause crashes the compiler #43321

Closed
ahoppen opened this issue Feb 10, 2016 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software regression swift 2.2

Comments

@ahoppen
Copy link
Contributor

ahoppen commented Feb 10, 2016

Previous ID SR-706
Radar rdar://problem/24590570
Original Reporter @ahoppen
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 2.2Regression, CompilerCrash
Assignee @slavapestov
Priority Medium

md5: 2ecb400a6d15f5385a8cf70c1d8fcda8

Issue Description:

When using the generic argument of a function as a parameter of another generic class that is used in the signature, the compiler crashes with Illegal instruction: 4

Example

class GenericClass<T> { }

protocol MyProtocol { }

class MyClass {
  func myFunction<T, O: GenericClass<T> where T: MyProtocol>(myArg: O) -> T {
    fatalError()
  }
}

Interesting crash facts

  • This used to work with Swift 2.1

  • This works with the version of Swift that is shipped with Xcode 7.3 beta 2 (7D129n)

  • It crashes the Swift 2.2 and Swift 3 compiler since the snapshot of 01/11/2016 (that’s the oldest snapshot I have installed)

  • The code compiles fine with the current master (as of 02/10/2016, commit 073df63) iff myFunction is a global function and not a method in a class

@jckarter
Copy link
Member

Committed a workaround that prevents the crash:

Master: 94a21ce
2.2: 0027316

@slavapestov is working on a more principled fix for master.

@slavapestov
Copy link
Member

This was fixed in master with this commit:

commit 3aacf5d
Author: Slava Pestov <spestov@apple.com>
Date: Wed Feb 10 14:14:35 2016 -0800

ArchetypeBuilder: Allow generic signature superclass constraints to contain type parameters

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 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 crash Bug: A crash, i.e., an abnormal termination of software regression swift 2.2
Projects
None yet
Development

No branches or pull requests

4 participants