Swift 2.2 regression bug: Using generic parameter as a generic argument in the same clause

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&gt;\). 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

Hi Alex,

I’m pretty sure Joe Groff pushed a fix for this yesterday (it landed in swift-2.2-branch with 9e9537 and master as c165811). I’ll double-check.

Thanks!
- Joe

···

On Feb 9, 2016, at 11:56 PM, Alex Hoppen via swift-dev <swift-dev@swift.org> wrote:

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&gt;\). 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
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

Hey Joe, I have another fix being tested for a regression handling generic parameters constrained by dependent generic base class constraints:

IRGen: Work around crash lowering generic base class-constrained type parameter. by jckarter · Pull Request #1257 · apple/swift · GitHub (master)
IRGen: Work around crash lowering generic base class-constrained type parameter. by jckarter · Pull Request #1258 · apple/swift · GitHub (2.2)

I'd like to pull this into 2.2, with your approval.

-Joe

I'm not certain that yesterday's fix would cover this case.

-Joe

···

On Feb 10, 2016, at 9:20 AM, Joe Pamer via swift-dev <swift-dev@swift.org> wrote:

Hi Alex,

I’m pretty sure Joe Groff pushed a fix for this yesterday (it landed in swift-2.2-branch with 9e9537 and master as c165811). I’ll double-check.

Thanks!
- Joe

On Feb 9, 2016, at 11:56 PM, Alex Hoppen via swift-dev <swift-dev@swift.org <mailto:swift-dev@swift.org>> wrote:

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&gt;\). 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
_______________________________________________
swift-dev mailing list
swift-dev@swift.org <mailto:swift-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-dev

_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

Thanks, Joe!

This change is approved for Swift 2.2. Please go ahead and cherry-pick it to swift-2.2-branch.

- Joe

···

On Feb 10, 2016, at 1:35 PM, Joe Groff <jgroff@apple.com> wrote:

Hey Joe, I have another fix being tested for a regression handling generic parameters constrained by dependent generic base class constraints:

IRGen: Work around crash lowering generic base class-constrained type parameter. by jckarter · Pull Request #1257 · apple/swift · GitHub (master)
IRGen: Work around crash lowering generic base class-constrained type parameter. by jckarter · Pull Request #1258 · apple/swift · GitHub (2.2)

I'd like to pull this into 2.2, with your approval.

-Joe

Hmm - you’re right. I tried compiling the example code on master, and didn’t see a crash. I just tried again, though, and now I do.

The stack trace is new to me, but it does look related to the ArchetypeBuilder changes.

- Joe

···

On Feb 10, 2016, at 9:29 AM, Joe Groff <jgroff@apple.com> wrote:

I'm not certain that yesterday's fix would cover this case.

-Joe

On Feb 10, 2016, at 9:20 AM, Joe Pamer via swift-dev <swift-dev@swift.org <mailto:swift-dev@swift.org>> wrote:

Hi Alex,

I’m pretty sure Joe Groff pushed a fix for this yesterday (it landed in swift-2.2-branch with 9e9537 and master as c165811). I’ll double-check.

Thanks!
- Joe

On Feb 9, 2016, at 11:56 PM, Alex Hoppen via swift-dev <swift-dev@swift.org <mailto:swift-dev@swift.org>> wrote:

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&gt;\). 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
_______________________________________________
swift-dev mailing list
swift-dev@swift.org <mailto:swift-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-dev

_______________________________________________
swift-dev mailing list
swift-dev@swift.org <mailto:swift-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-dev