Skip to content

Commit faf13ad

Browse files
paldepindCopilot
andcommitted
Unified: Add corpus tests for attributed parameter types
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b6a9c9a commit faf13ad

4 files changed

Lines changed: 300 additions & 0 deletions

File tree

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
func f<D, T>(
2+
a: inout D,
3+
b: sending T,
4+
c: borrowing T,
5+
d: consuming T,
6+
e: @escaping (T) -> Void,
7+
g: @Sendable @escaping () -> D
8+
) {}
9+
10+
---
11+
12+
sourceFile
13+
endOfFileToken: endOfFile
14+
statements:
15+
codeBlockItem
16+
item:
17+
functionDecl
18+
attributes:
19+
body:
20+
codeBlock
21+
leftBrace: {
22+
rightBrace: }
23+
statements:
24+
name: identifier "f"
25+
genericParameterClause:
26+
genericParameterClause
27+
parameters:
28+
genericParameter
29+
attributes:
30+
name: identifier "D"
31+
trailingComma: ,
32+
genericParameter
33+
attributes:
34+
name: identifier "T"
35+
leftAngle: <
36+
rightAngle: >
37+
modifiers:
38+
signature:
39+
functionSignature
40+
parameterClause:
41+
functionParameterClause
42+
leftParen: (
43+
rightParen: )
44+
parameters:
45+
functionParameter
46+
colon: :
47+
attributes:
48+
modifiers:
49+
trailingComma: ,
50+
type:
51+
attributedType
52+
attributes:
53+
baseType:
54+
identifierType
55+
name: identifier "D"
56+
lateSpecifiers:
57+
specifiers:
58+
simpleTypeSpecifier
59+
specifier: inout
60+
firstName: identifier "a"
61+
functionParameter
62+
colon: :
63+
attributes:
64+
modifiers:
65+
trailingComma: ,
66+
type:
67+
attributedType
68+
attributes:
69+
baseType:
70+
identifierType
71+
name: identifier "T"
72+
lateSpecifiers:
73+
specifiers:
74+
simpleTypeSpecifier
75+
specifier: sending
76+
firstName: identifier "b"
77+
functionParameter
78+
colon: :
79+
attributes:
80+
modifiers:
81+
trailingComma: ,
82+
type:
83+
attributedType
84+
attributes:
85+
baseType:
86+
identifierType
87+
name: identifier "T"
88+
lateSpecifiers:
89+
specifiers:
90+
simpleTypeSpecifier
91+
specifier: borrowing
92+
firstName: identifier "c"
93+
functionParameter
94+
colon: :
95+
attributes:
96+
modifiers:
97+
trailingComma: ,
98+
type:
99+
attributedType
100+
attributes:
101+
baseType:
102+
identifierType
103+
name: identifier "T"
104+
lateSpecifiers:
105+
specifiers:
106+
simpleTypeSpecifier
107+
specifier: consuming
108+
firstName: identifier "d"
109+
functionParameter
110+
colon: :
111+
attributes:
112+
modifiers:
113+
trailingComma: ,
114+
type:
115+
attributedType
116+
attributes:
117+
attribute
118+
atSign: @
119+
attributeName:
120+
identifierType
121+
name: identifier "escaping"
122+
baseType:
123+
functionType
124+
leftParen: (
125+
rightParen: )
126+
parameters:
127+
tupleTypeElement
128+
type:
129+
identifierType
130+
name: identifier "T"
131+
returnClause:
132+
returnClause
133+
arrow: ->
134+
type:
135+
identifierType
136+
name: identifier "Void"
137+
lateSpecifiers:
138+
specifiers:
139+
firstName: identifier "e"
140+
functionParameter
141+
colon: :
142+
attributes:
143+
modifiers:
144+
type:
145+
attributedType
146+
attributes:
147+
attribute
148+
atSign: @
149+
attributeName:
150+
identifierType
151+
name: identifier "Sendable"
152+
attribute
153+
atSign: @
154+
attributeName:
155+
identifierType
156+
name: identifier "escaping"
157+
baseType:
158+
functionType
159+
leftParen: (
160+
rightParen: )
161+
parameters:
162+
returnClause:
163+
returnClause
164+
arrow: ->
165+
type:
166+
identifierType
167+
name: identifier "D"
168+
lateSpecifiers:
169+
specifiers:
170+
firstName: identifier "g"
171+
funcKeyword: func
172+
173+
---
174+
175+
top_level source="⟨body⟩"
176+
body:
177+
block source="⟨stmt⟩"
178+
stmt:
179+
function_declaration source="func ⟨name_node⟩<⟨type_parameter⟩, ⟨type_parameter⟩>(\n ⟨parameter⟩,\n ⟨parameter⟩,\n ⟨parameter⟩,\n ⟨parameter⟩,\n ⟨parameter⟩,\n ⟨parameter⟩\n) ⟨body⟩"
180+
name_node: identifier "f" source="f"
181+
type_parameter:
182+
type_parameter source="⟨name_node⟩"
183+
name_node: identifier "D" source="D"
184+
type_parameter source="⟨name_node⟩"
185+
name_node: identifier "T" source="T"
186+
parameter:
187+
parameter source="⟨external_name_node⟩⟨pattern⟩: ⟨type⟩"
188+
external_name_node: identifier "a" source="a"
189+
type: unsupported_node "inout D" source="inout D"
190+
pattern: identifier "a" source="a"
191+
parameter source="⟨external_name_node⟩⟨pattern⟩: ⟨type⟩"
192+
external_name_node: identifier "b" source="b"
193+
type: unsupported_node "sending T" source="sending T"
194+
pattern: identifier "b" source="b"
195+
parameter source="⟨external_name_node⟩⟨pattern⟩: ⟨type⟩"
196+
external_name_node: identifier "c" source="c"
197+
type: unsupported_node "borrowing T" source="borrowing T"
198+
pattern: identifier "c" source="c"
199+
parameter source="⟨external_name_node⟩⟨pattern⟩: ⟨type⟩"
200+
external_name_node: identifier "d" source="d"
201+
type: unsupported_node "consuming T" source="consuming T"
202+
pattern: identifier "d" source="d"
203+
parameter source="⟨external_name_node⟩⟨pattern⟩: ⟨type⟩"
204+
external_name_node: identifier "e" source="e"
205+
type: unsupported_node "@escaping (T) -> Void" source="@escaping (T) -> Void"
206+
pattern: identifier "e" source="e"
207+
parameter source="⟨external_name_node⟩⟨pattern⟩: ⟨type⟩"
208+
external_name_node: identifier "g" source="g"
209+
type: unsupported_node "@Sendable @escaping () -> D" source="@Sendable @escaping () -> D"
210+
pattern: identifier "g" source="g"
211+
body: block "{}" source="{}"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
func f<D, T>(
2+
a: inout D,
3+
b: sending T,
4+
c: borrowing T,
5+
d: consuming T,
6+
e: @escaping (T) -> Void,
7+
g: @Sendable @escaping () -> D
8+
) {}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
let f: (inout Int) -> Void = { _ in }
2+
3+
---
4+
5+
sourceFile
6+
endOfFileToken: endOfFile
7+
statements:
8+
codeBlockItem
9+
item:
10+
variableDecl
11+
attributes:
12+
modifiers:
13+
bindingSpecifier: let
14+
bindings:
15+
patternBinding
16+
initializer:
17+
initializerClause
18+
equal: =
19+
value:
20+
closureExpr
21+
leftBrace: {
22+
rightBrace: }
23+
signature:
24+
closureSignature
25+
attributes:
26+
inKeyword: in
27+
parameterClause:
28+
closureShorthandParameter
29+
name: _
30+
statements:
31+
pattern:
32+
identifierPattern
33+
identifier: identifier "f"
34+
typeAnnotation:
35+
typeAnnotation
36+
colon: :
37+
type:
38+
functionType
39+
leftParen: (
40+
rightParen: )
41+
parameters:
42+
tupleTypeElement
43+
type:
44+
attributedType
45+
attributes:
46+
baseType:
47+
identifierType
48+
name: identifier "Int"
49+
lateSpecifiers:
50+
specifiers:
51+
simpleTypeSpecifier
52+
specifier: inout
53+
returnClause:
54+
returnClause
55+
arrow: ->
56+
type:
57+
identifierType
58+
name: identifier "Void"
59+
60+
---
61+
62+
top_level source="⟨body⟩"
63+
body:
64+
block source="⟨stmt⟩"
65+
stmt:
66+
variable_declaration source="⟨modifier⟩ ⟨pattern⟩: ⟨type⟩ = ⟨value⟩"
67+
modifier: modifier "let" source="let"
68+
pattern: identifier "f" source="f"
69+
type:
70+
function_expr source="(⟨parameter⟩) -> ⟨return_type⟩"
71+
parameter:
72+
parameter source="⟨type⟩"
73+
type: unsupported_node "inout Int" source="inout Int"
74+
return_type: identifier "Void" source="Void"
75+
value:
76+
function_expr source="{ ⟨parameter⟩ in }"
77+
parameter:
78+
parameter source="⟨pattern⟩"
79+
pattern: identifier "_" source="_"
80+
body: block source=""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let f: (inout Int) -> Void = { _ in }

0 commit comments

Comments
 (0)