[swift-dev] Swift 2.2 regression bug: Using generic parameter as a generic argument in the same clause

Alex Hoppen alex at ateamer.de
Wed Feb 10 01:56:38 CST 2016


Hi everyone,

I just found a major regression bug in Swift 2.2 (it’s tracked under SR-706 <https://bugs.swift.org/browse/SR-706>). Since Swift 2.2 development seems to come to an end I wanted to raise some attention for this bug by posting it here as well.

- Alex



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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160210/48be99d7/attachment.html>


More information about the swift-dev mailing list