- Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathissue-58149-generic-signature-builder-keypath-iterable.swift
50 lines (40 loc) · 1.43 KB
/
issue-58149-generic-signature-builder-keypath-iterable.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// RUN: %target-swift-frontend -emit-sil -verify %s
// https://github.com/apple/swift/issues/58149
// Crash while compiling Swift for TensorFlow
//
// This was caused by a bug in GenericSignatureBuilder, similar to one involving
// `CaseIterable`. In this reproducer, `KeyPathIterable` is similar enough to
// `CaseIterable` to have caused the GSB to crash. It was fixed by
// RequirementMachine abstract signatures.
import _Differentiation
@_spi(Reflection)import Swift
structRNNCellInput<Input>:Differentiable{}
structRNNCellOutput<Output>:Differentiable{}
protocolLayer:Differentiable{
associatedtypeInput
associatedtypeOutput:Differentiable
@differentiable(reverse)
func callAsFunction(_ input:Input)->Output
}
publicprotocolKeyPathIterable{
associatedtypeAllKeyPaths:Sequence
where AllKeyPaths.Element ==PartialKeyPath<Self>
}
protocolRecurrentLayerCell:Layer,KeyPathIterable
where
Input ==RNNCellInput<TimeStepInput>,
Output ==RNNCellOutput<TimeStepOutput>
{
associatedtypeTimeStepInput
associatedtypeTimeStepOutput:Differentiable
}
structRecurrentLayer<Cell:RecurrentLayerCell>:Layer{
typealiasInput=Cell.TimeStepInput
typealiasOutput=Cell.TimeStepOutput
varcell:Cell
@differentiable(reverse)
func callAsFunction(_ inputs:Cell.TimeStepInput)->Cell.TimeStepOutput{
// expected-warning @+1 {{function call causes an infinite recursion}}
returnself(inputs)
}
}