Skip to content

Commit 358fe1a

Browse files
committed
unified: Fix stale field name
1 parent 02824fb commit 358fe1a

6 files changed

Lines changed: 40 additions & 17 deletions

unified/extractor/src/languages/swift/swift.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
391391
(accessor_declaration
392392
modifier: {binding}
393393
modifier: {chained}
394-
name: {name}
394+
name_node: {name}
395395
type: {ty}
396396
accessor_kind: (accessor_kind #{spec})
397397
body: {body})

unified/extractor/tests/corpus/swift/types/binding-modifier-does-not-leak-into-accessor-body.output

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ top_level
9898
stmt:
9999
accessor_declaration
100100
modifier: modifier "var"
101+
name_node: name_node "p"
101102
accessor_kind: accessor_kind "get"
102103
type: name_node "Int"
103104
body:
@@ -119,5 +120,3 @@ top_level
119120
stmt:
120121
return_expr
121122
value: int_literal "2"
122-
name: name_node "p" <-- ERROR: the node 'accessor_declaration' has no field 'name'
123-
<-- ERROR: missing required field 'name_node'

unified/extractor/tests/corpus/swift/types/property-with-getter-and-setter.output

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,19 @@ top_level
118118
value: int_literal "0"
119119
accessor_declaration
120120
modifier: modifier "var"
121+
name_node: name_node "v"
121122
accessor_kind: accessor_kind "get"
122123
type: name_node "Int"
123124
body:
124125
block
125126
stmt:
126127
return_expr
127128
value: name_node "_v"
128-
name: name_node "v" <-- ERROR: the node 'accessor_declaration' has no field 'name'
129-
<-- ERROR: missing required field 'name_node'
130129
accessor_declaration
131130
modifier:
132131
modifier "var"
133132
modifier "chained_declaration"
133+
name_node: name_node "v"
134134
accessor_kind: accessor_kind "set"
135135
type: name_node "Int"
136136
body:
@@ -139,5 +139,3 @@ top_level
139139
assign_expr
140140
target: name_node "_v"
141141
value: name_node "newValue"
142-
name: name_node "v" <-- ERROR: the node 'accessor_declaration' has no field 'name'
143-
<-- ERROR: missing required field 'name_node'

unified/extractor/tests/corpus/swift/types/protocol-with-read-only-and-read-write-property-requirements.output

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
protocol P {
22
var foo: Int { get }
33
var bar: String { get set }
4+
var count: Int { get }
45
}
56

67
---
@@ -71,6 +72,31 @@ sourceFile
7172
attributes:
7273
leftBrace: {
7374
rightBrace: }
75+
memberBlockItem
76+
decl:
77+
variableDecl
78+
attributes:
79+
modifiers:
80+
bindingSpecifier: var
81+
bindings:
82+
patternBinding
83+
pattern:
84+
identifierPattern
85+
identifier: identifier "count"
86+
typeAnnotation:
87+
typeAnnotation
88+
colon: :
89+
type:
90+
identifierType
91+
name: identifier "Int"
92+
accessorBlock:
93+
accessorBlock
94+
accessors:
95+
accessorDecl
96+
accessorSpecifier: get
97+
attributes:
98+
leftBrace: {
99+
rightBrace: }
74100
modifiers:
75101
protocolKeyword: protocol
76102

@@ -85,18 +111,19 @@ top_level
85111
name_node: name_node "P"
86112
member:
87113
accessor_declaration
114+
name_node: name_node "foo"
88115
accessor_kind: accessor_kind "get"
89116
type: name_node "Int"
90-
name: name_node "foo" <-- ERROR: the node 'accessor_declaration' has no field 'name'
91-
<-- ERROR: missing required field 'name_node'
92117
accessor_declaration
118+
name_node: name_node "bar"
93119
accessor_kind: accessor_kind "get"
94120
type: name_node "String"
95-
name: name_node "bar" <-- ERROR: the node 'accessor_declaration' has no field 'name'
96-
<-- ERROR: missing required field 'name_node'
97121
accessor_declaration
98122
modifier: modifier "chained_declaration"
123+
name_node: name_node "bar"
99124
accessor_kind: accessor_kind "set"
100125
type: name_node "String"
101-
name: name_node "bar" <-- ERROR: the node 'accessor_declaration' has no field 'name'
102-
<-- ERROR: missing required field 'name_node'
126+
accessor_declaration
127+
name_node: name_node "count"
128+
accessor_kind: accessor_kind "get"
129+
type: name_node "Int"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
protocol P {
22
var foo: Int { get }
33
var bar: String { get set }
4+
var count: Int { get }
45
}

unified/extractor/tests/corpus/swift/variables/property-with-willset-and-didset-observers.output

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ top_level
114114
modifier:
115115
modifier "var"
116116
modifier "chained_declaration"
117+
name_node: name_node "x"
117118
accessor_kind: accessor_kind "willSet"
118119
body:
119120
block
@@ -123,12 +124,11 @@ top_level
123124
argument:
124125
argument
125126
value: name_node "newValue"
126-
name: name_node "x" <-- ERROR: the node 'accessor_declaration' has no field 'name'
127-
<-- ERROR: missing required field 'name_node'
128127
accessor_declaration
129128
modifier:
130129
modifier "var"
131130
modifier "chained_declaration"
131+
name_node: name_node "x"
132132
accessor_kind: accessor_kind "didSet"
133133
body:
134134
block
@@ -138,5 +138,3 @@ top_level
138138
argument:
139139
argument
140140
value: name_node "oldValue"
141-
name: name_node "x" <-- ERROR: the node 'accessor_declaration' has no field 'name'
142-
<-- ERROR: missing required field 'name_node'

0 commit comments

Comments
 (0)