-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emit reabstraction thunks for implicit conversions between T.TangentT…
…ype and Optional<T>.TangentType Fixes #77924
- Loading branch information
Showing
3 changed files
with
126 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
test/AutoDiff/compiler_crashers_fixed/issue-77871-implicit-diff-optional-conversion.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// RUN: %target-swift-frontend -emit-sil -verify %s | ||
|
||
// https://github.com/swiftlang/swift/issues/77871 | ||
// Ensure we are correctl generating reabstraction thunks for Double <-> Optional<Double> | ||
// conversion for derivatives: for differential and pullback we need | ||
// to emit thunks to convert T.TangentVector <-> Optional<T>.TangentVector. | ||
|
||
import _Differentiation | ||
|
||
@differentiable(reverse) | ||
func testFunc(_ x: Double?) -> Double? { | ||
x! * x! * x! | ||
} | ||
print(pullback(at: 1.0, of: testFunc)(.init(1.0)) == 3.0) | ||
|