You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For all non-`@noDerivative` parameter and result types, `@differentiable(linear)`
function types should require and imply `T: Differentiable`, `T == T.TangentVector`
requirements instead of `T: Differentiable & AdditiveArithmetic`.
Emit `@noDerivative` fixit only when there is at least one valid
differentiability/linearity parameter. Otherwise, adding `@noDerivative`
produces an ill-formed `@differentiable` function type.
Update tests.
// FIXME: Properly type-check parameters and the result's differentiability
12
-
// expected-error @+1 {{argument is not differentiable, but the enclosing function type is marked '@differentiable'}} {{25-25=@noDerivative }}
13
+
// expected-error @+1 {{parameter type 'NonDiffType' does not conform to 'Differentiable', but the enclosing function type is '@differentiable'}}
13
14
let _:@differentiable(NonDiffType)->Float
14
-
// expected-error @+1 {{result is not differentiable, but the function type is marked '@differentiable'}}
15
+
16
+
// Emit `@noDerivative` fixit iff there is at least one valid differentiability parameter.
17
+
// expected-error @+1 {{parameter type 'NonDiffType' does not conform to 'Differentiable', but the enclosing function type is '@differentiable'; did you want to add '@noDerivative' to this parameter?}} {{32-32=@noDerivative }}
18
+
let _:@differentiable(Float,NonDiffType)->Float
19
+
20
+
// expected-error @+1 {{result type 'NonDiffType' does not conform to 'Differentiable' and satisfy 'NonDiffType == NonDiffType.TangentVector', but the enclosing function type is '@differentiable(linear)'}}
21
+
let _:@differentiable(linear)(Float)->NonDiffType
22
+
23
+
// Emit `@noDerivative` fixit iff there is at least one valid linearity parameter.
24
+
// expected-error @+1 {{parameter type 'NonDiffType' does not conform to 'Differentiable' and satisfy 'NonDiffType == NonDiffType.TangentVector', but the enclosing function type is '@differentiable(linear)'; did you want to add '@noDerivative' to this parameter?}} {{40-40=@noDerivative }}
25
+
let _:@differentiable(linear)(Float,NonDiffType)->Float
26
+
27
+
// expected-error @+1 {{result type 'NonDiffType' does not conform to 'Differentiable', but the enclosing function type is '@differentiable'}}
15
28
let _:@differentiable(Float)->NonDiffType
16
29
30
+
// expected-error @+1 {{result type 'NonDiffType' does not conform to 'Differentiable' and satisfy 'NonDiffType == NonDiffType.TangentVector', but the enclosing function type is '@differentiable(linear)'}}
// expected-error @+2 {{result is not differentiable, but the function type is marked '@differentiable'}}
84
-
// expected-error @+1 {{result is not differentiable, but the function type is marked '@differentiable'}}
99
+
// expected-error @+2 {{result type 'Int' does not conform to 'Differentiable', but the enclosing function type is '@differentiable'}}
100
+
// expected-error @+1 {{result type '@differentiable (U) -> Int' does not conform to 'Differentiable', but the enclosing function type is '@differentiable'}}
// expected-error @+5 {{generic signature requires types 'Vector<T>' and 'Vector<T>.TangentVector' to be the same}}
133
+
// expected-error @+4 {{generic signature requires types 'Vector<U>' and 'Vector<U>.TangentVector' to be the same}}
134
+
// expected-error @+3 {{parameter type 'Vector<T>' does not conform to 'Differentiable' and satisfy 'Vector<T> == Vector<T>.TangentVector', but the enclosing function type is '@differentiable(linear)'}}
135
+
// expected-error @+2 {{result type 'Vector<U>' does not conform to 'Differentiable' and satisfy 'Vector<U> == Vector<U>.TangentVector', but the enclosing function type is '@differentiable(linear)'}}
// expected-error @+4 {{generic signature requires types 'Vector<T>' and 'Vector<T>.TangentVector' to be the same}}
150
+
// expected-error @+3 {{generic signature requires types 'Vector<U>' and 'Vector<U>.TangentVector' to be the same}}
151
+
// expected-error @+2 {{parameter type 'Vector<T>' does not conform to 'Differentiable' and satisfy 'Vector<T> == Vector<T>.TangentVector', but the enclosing function type is '@differentiable(linear)'}}
152
+
// expected-error @+1 {{result type 'Vector<U>' does not conform to 'Differentiable' and satisfy 'Vector<U> == Vector<U>.TangentVector', but the enclosing function type is '@differentiable(linear)'}}
0 commit comments