@@ -60,19 +60,19 @@ func fakeGradient<T, U: FloatingPoint>(of f: @differentiable (T) -> U) {}
60
60
61
61
func takesOpaqueClosure( f: @escaping ( Float ) -> Float ) {
62
62
// expected-note @-1 {{did you mean to take a '@differentiable' closure?}} {{38-38=@differentiable }}
63
- // expected-error @+1 {{a '@differentiable' function can only be formed from a reference to a 'func' or a literal closure}}
63
+ // expected-error @+1 {{a '@differentiable' function can only be formed from a reference to a 'func' or 'init' or a literal closure}}
64
64
fakeGradient ( of: f)
65
65
}
66
66
67
67
let globalAddOne : ( Float ) -> Float = { $0 + 1 }
68
- // expected-error @+1 {{a '@differentiable' function can only be formed from a reference to a 'func' or a literal closure}}
68
+ // expected-error @+1 {{a '@differentiable' function can only be formed from a reference to a 'func' or 'init' or a literal closure}}
69
69
fakeGradient ( of: globalAddOne)
70
70
71
71
func someScope( ) {
72
72
let localAddOne : ( Float ) -> Float = { $0 + 1 }
73
- // expected-error @+1 {{a '@differentiable' function can only be formed from a reference to a 'func' or a literal closure}}
73
+ // expected-error @+1 {{a '@differentiable' function can only be formed from a reference to a 'func' or 'init' or a literal closure}}
74
74
fakeGradient ( of: globalAddOne)
75
- // expected-error @+1 {{a '@differentiable' function can only be formed from a reference to a 'func' or a literal closure}}
75
+ // expected-error @+1 {{a '@differentiable' function can only be formed from a reference to a 'func' or 'init' or a literal closure}}
76
76
fakeGradient ( of: localAddOne)
77
77
// The following case is okay during type checking, but will fail in the AD transform.
78
78
fakeGradient { localAddOne ( $0) }
@@ -95,10 +95,15 @@ func linearToDifferentiable(_ f: @escaping @differentiable(linear) (Float) -> Fl
95
95
}
96
96
97
97
func differentiableToLinear( _ f: @escaping @differentiable ( Float ) -> Float ) {
98
- // expected-error @+1 {{a '@differentiable(linear)' function can only be formed from a reference to a 'func' or a literal closure}}
98
+ // expected-error @+1 {{a '@differentiable(linear)' function can only be formed from a reference to a 'func' or 'init' or a literal closure}}
99
99
_ = f as @differentiable ( linear) ( Float ) -> Float
100
100
}
101
101
102
+ struct Struct : Differentiable {
103
+ var x : Float
104
+ }
105
+ let _: @differentiable ( Float ) -> Struct = Struct . init
106
+
102
107
//===----------------------------------------------------------------------===//
103
108
// Parameter selection (@noDerivative)
104
109
//===----------------------------------------------------------------------===//
0 commit comments