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-15667] [AutoDiff] Providing exact type for generic parameter in @differentiable can lead to an assertion failure #57946
Comments
I have narrowed down the regression further. Perhaps the differentiable function being called here is import _Differentiation
// `Root` can be constrained to `Differentiable` here, rather than in the
// extension. The crash happens either way.
struct TestKeyPaths<Root, Value>{}
// Adding `where Value == Int` causes the crash. Either removing that or
// substituting with `where Value: Differentiable` eliminates the crash.
extension TestKeyPaths where Root: Differentiable, Value == Int {
@differentiable(reverse)
static func readAll(from root: Root) -> Double {
// Removing the force-unwrap eliminates the crash.
let ignored = Root?(nil)!
return 0
}
} Build output
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Additional Detail from JIRA
md5: 30987d0cfba9255fa519471be9e3d5bd
Issue Description:
When a differentiable function refines a generic parameter to a specific type, but a differentiable function called within that function isn't as refined, it can sometimes lead to an assertion failure of "(OrigType == signature.getCanonicalTypeInContext(origType)), function initSwiftType, file AbstractionPattern.h, line 533".
The following single-file reproducer triggers this:
To observe the assertion failure, place the above in a file and build via `swiftc file.swift`. The assertion failure goes away if the line
@differentiable(reverse where Root: Differentiable, Value == Float)
is replaced with
@differentiable(reverse where Root: Differentiable, Value: Differentiable)
This appears to not be a recent regression, and is present in current nightly toolchain snapshots. The full text of the assertion failure is as follows:
The text was updated successfully, but these errors were encountered: