Skip to content

Commit e7f856f

Browse files
authored
[AutoDiff] Add SR-12744 negative test. (swiftlang#31680)
Add negative test for SR-12744: pullback generation crash for unhandled indirect result.
1 parent c721cf1 commit e7f856f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: not --crash %target-swift-frontend -emit-sil -verify %s
2+
// REQUIRES: asserts
3+
4+
// SR-12744: Pullback generation crash for unhandled indirect result.
5+
// May be due to inconsistent derivative function type calculation logic in
6+
// `VJPEmitter::createEmptyPullback`.
7+
8+
import _Differentiation
9+
10+
class Class: Differentiable {
11+
@differentiable(wrt: (self, x))
12+
@differentiable(wrt: x)
13+
func f(_ x: Float) -> Float { x }
14+
}
15+
16+
func test<C: Class>(_ c: C, _ x: Float) {
17+
_ = gradient(at: c, x) { c, x in c.f(x) }
18+
_ = gradient(at: x) { x in c.f(x) }
19+
}

0 commit comments

Comments
 (0)