blob: c0f07a5c3e898e63f68b4b5911815b370f8f5345 [file] [log] [blame]
// RUN: %target-swift-frontend -emit-sil -verify %s
// This test file contains SIL diagnostics tests for differentiable functions
// such as escaping capture errors.
// NOTE: Only add tests for errors that would occur after the differentiation
// transform.
func nonescapingArgument(f: @differentiable (Float, Float) -> Float) -> Float {
return gradient(at: 1) { x in f(x, x) }
}
// expected-note @+2 {{parameter 'f' is implicitly non-escaping}}
func nonescapingArgumentError(
f: @differentiable (Float, Float) -> Float
) -> @differentiable (Float) -> Float{
// expected-error @+2 {{escaping closure captures non-escaping parameter 'f'}}
// expected-note @+1 {{captured here}}
return { x in f(x, x) }
}