Open BradLarson opened 2 years ago
I have narrowed down the regression further. Perhaps the differentiable function being called here is Optional.!
. It originated some time between the 2021-01-27 and 2021-07-07 toolchains.
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
}
}
Still crashes on 05/24 toolchain.
Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, AutoDiff | |Assignee | None | |Priority | Medium | md5: 30987d0cfba9255fa519471be9e3d5bdIssue 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
is replaced with
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: