mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
* Lookup for custom derivatives in non-primary source files after typecheck is finished for the primary source. This registers all custom derivatives before autodiff transformations and makes them available to them. Fully resolves #55170
10 lines
338 B
Swift
10 lines
338 B
Swift
// RUN: %target-swift-frontend -emit-sil -verify -primary-file %s %S/Inputs/derivatives.swift -module-name main -o /dev/null
|
|
|
|
import _Differentiation
|
|
|
|
@differentiable(reverse)
|
|
func clamp(_ value: Double, _ lowerBound: Double, _ upperBound: Double) -> Double {
|
|
// No error expected
|
|
return max(min(value, upperBound), lowerBound)
|
|
}
|