Files
swift-mirror/test/AutoDiff/compiler_crashers_fixed/issue-75280-guard-let-optional.swift
Anton Korobeynikov a751b076b6 Fixes inject_enum_addr handling: (#75459)
- Ensure it really accumulates the adjoint buffer
- Handle Optional.none case when there is no value to propagate to

Fixes #75280
2024-07-26 17:04:26 -07:00

14 lines
469 B
Swift

// RUN: %target-swift-frontend -emit-sil -verify %s
// https://github.com/swiftlang/swift/issues/75280
// Ensure we accumulate adjoints properly for inject_enum_addr instructions and
// handle `nil` case (no adjoint value to propagate)
import _Differentiation
@differentiable(reverse) func a<F, A>(_ f: Optional<F>, c: @differentiable(reverse) (F) -> A) -> Optional<A> where F: Differentiable, A: Differentiable
{
guard let f else {return nil}
return c(f)
}