rbs 4.0.0.dev.5 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/c-check.yml +8 -4
  3. data/.github/workflows/comments.yml +3 -1
  4. data/.github/workflows/dependabot.yml +1 -1
  5. data/.github/workflows/ruby.yml +10 -0
  6. data/.github/workflows/rust.yml +95 -0
  7. data/CHANGELOG.md +323 -0
  8. data/Rakefile +12 -29
  9. data/Steepfile +1 -0
  10. data/config.yml +393 -37
  11. data/core/array.rbs +218 -188
  12. data/core/basic_object.rbs +9 -8
  13. data/core/class.rbs +6 -5
  14. data/core/comparable.rbs +45 -31
  15. data/core/complex.rbs +52 -40
  16. data/core/dir.rbs +57 -45
  17. data/core/encoding.rbs +5 -5
  18. data/core/enumerable.rbs +96 -91
  19. data/core/enumerator.rbs +4 -3
  20. data/core/errno.rbs +3 -2
  21. data/core/errors.rbs +31 -29
  22. data/core/exception.rbs +12 -12
  23. data/core/fiber.rbs +36 -36
  24. data/core/file.rbs +186 -113
  25. data/core/file_test.rbs +2 -2
  26. data/core/float.rbs +41 -32
  27. data/core/gc.rbs +78 -70
  28. data/core/hash.rbs +70 -60
  29. data/core/integer.rbs +32 -28
  30. data/core/io/buffer.rbs +36 -36
  31. data/core/io/wait.rbs +7 -7
  32. data/core/io.rbs +120 -135
  33. data/core/kernel.rbs +189 -139
  34. data/core/marshal.rbs +3 -3
  35. data/core/match_data.rbs +14 -12
  36. data/core/math.rbs +69 -67
  37. data/core/method.rbs +6 -6
  38. data/core/module.rbs +146 -85
  39. data/core/nil_class.rbs +4 -3
  40. data/core/numeric.rbs +35 -32
  41. data/core/object.rbs +6 -8
  42. data/core/object_space.rbs +11 -10
  43. data/core/pathname.rbs +131 -81
  44. data/core/proc.rbs +65 -33
  45. data/core/process.rbs +219 -201
  46. data/core/ractor.rbs +15 -11
  47. data/core/random.rbs +4 -3
  48. data/core/range.rbs +52 -47
  49. data/core/rational.rbs +5 -5
  50. data/core/rbs/unnamed/argf.rbs +58 -51
  51. data/core/rbs/unnamed/env_class.rbs +18 -13
  52. data/core/rbs/unnamed/main_class.rbs +123 -0
  53. data/core/rbs/unnamed/random.rbs +7 -5
  54. data/core/regexp.rbs +236 -197
  55. data/core/ruby.rbs +1 -1
  56. data/core/ruby_vm.rbs +32 -30
  57. data/core/rubygems/config_file.rbs +5 -5
  58. data/core/rubygems/errors.rbs +1 -1
  59. data/core/rubygems/requirement.rbs +5 -5
  60. data/core/rubygems/rubygems.rbs +5 -3
  61. data/core/set.rbs +17 -16
  62. data/core/signal.rbs +2 -2
  63. data/core/string.rbs +311 -292
  64. data/core/struct.rbs +26 -25
  65. data/core/symbol.rbs +25 -24
  66. data/core/thread.rbs +40 -34
  67. data/core/time.rbs +47 -42
  68. data/core/trace_point.rbs +34 -31
  69. data/core/true_class.rbs +2 -2
  70. data/core/unbound_method.rbs +10 -10
  71. data/core/warning.rbs +7 -7
  72. data/docs/collection.md +1 -1
  73. data/docs/config.md +171 -0
  74. data/docs/inline.md +110 -4
  75. data/docs/syntax.md +13 -12
  76. data/ext/rbs_extension/ast_translation.c +489 -135
  77. data/ext/rbs_extension/class_constants.c +8 -0
  78. data/ext/rbs_extension/class_constants.h +4 -0
  79. data/ext/rbs_extension/legacy_location.c +28 -51
  80. data/ext/rbs_extension/legacy_location.h +37 -0
  81. data/ext/rbs_extension/main.c +12 -20
  82. data/include/rbs/ast.h +423 -195
  83. data/include/rbs/lexer.h +2 -2
  84. data/include/rbs/location.h +25 -44
  85. data/include/rbs/parser.h +2 -2
  86. data/include/rbs/util/rbs_constant_pool.h +0 -3
  87. data/include/rbs.h +8 -0
  88. data/lib/rbs/ast/ruby/annotations.rb +157 -4
  89. data/lib/rbs/ast/ruby/members.rb +374 -22
  90. data/lib/rbs/cli/validate.rb +5 -60
  91. data/lib/rbs/collection/config/lockfile_generator.rb +6 -2
  92. data/lib/rbs/definition_builder.rb +60 -27
  93. data/lib/rbs/errors.rb +0 -11
  94. data/lib/rbs/inline_parser.rb +1 -1
  95. data/lib/rbs/parser_aux.rb +20 -7
  96. data/lib/rbs/prototype/helpers.rb +57 -0
  97. data/lib/rbs/prototype/rb.rb +1 -26
  98. data/lib/rbs/prototype/rbi.rb +1 -20
  99. data/lib/rbs/test/type_check.rb +3 -0
  100. data/lib/rbs/types.rb +62 -52
  101. data/lib/rbs/unit_test/type_assertions.rb +35 -8
  102. data/lib/rbs/version.rb +1 -1
  103. data/lib/rbs.rb +0 -1
  104. data/rbs.gemspec +1 -1
  105. data/rust/.gitignore +1 -0
  106. data/rust/Cargo.lock +378 -0
  107. data/rust/Cargo.toml +7 -0
  108. data/rust/ruby-rbs/Cargo.toml +22 -0
  109. data/rust/ruby-rbs/build.rs +764 -0
  110. data/rust/ruby-rbs/examples/locations.rs +60 -0
  111. data/rust/ruby-rbs/src/lib.rs +1 -0
  112. data/rust/ruby-rbs/src/node/mod.rs +742 -0
  113. data/rust/ruby-rbs/tests/sanity.rs +47 -0
  114. data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
  115. data/rust/ruby-rbs-sys/Cargo.toml +23 -0
  116. data/rust/ruby-rbs-sys/build.rs +204 -0
  117. data/rust/ruby-rbs-sys/src/lib.rs +50 -0
  118. data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
  119. data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
  120. data/rust/ruby-rbs-sys/wrapper.h +1 -0
  121. data/sig/ast/ruby/annotations.rbs +191 -4
  122. data/sig/ast/ruby/members.rbs +21 -1
  123. data/sig/cli/validate.rbs +1 -6
  124. data/sig/definition_builder.rbs +2 -0
  125. data/sig/errors.rbs +0 -8
  126. data/sig/method_types.rbs +1 -1
  127. data/sig/parser.rbs +17 -13
  128. data/sig/prototype/helpers.rbs +2 -0
  129. data/sig/types.rbs +10 -11
  130. data/sig/unit_test/spy.rbs +0 -8
  131. data/sig/unit_test/type_assertions.rbs +11 -0
  132. data/src/ast.c +339 -161
  133. data/src/lexstate.c +1 -1
  134. data/src/location.c +8 -48
  135. data/src/parser.c +674 -480
  136. data/src/util/rbs_constant_pool.c +0 -4
  137. data/stdlib/bigdecimal/0/big_decimal.rbs +16 -16
  138. data/stdlib/cgi-escape/0/escape.rbs +4 -4
  139. data/stdlib/coverage/0/coverage.rbs +4 -3
  140. data/stdlib/date/0/date.rbs +33 -28
  141. data/stdlib/date/0/date_time.rbs +24 -23
  142. data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
  143. data/stdlib/erb/0/erb.rbs +64 -53
  144. data/stdlib/etc/0/etc.rbs +55 -50
  145. data/stdlib/fileutils/0/fileutils.rbs +138 -125
  146. data/stdlib/forwardable/0/forwardable.rbs +10 -10
  147. data/stdlib/io-console/0/io-console.rbs +2 -2
  148. data/stdlib/json/0/json.rbs +135 -108
  149. data/stdlib/monitor/0/monitor.rbs +3 -3
  150. data/stdlib/net-http/0/net-http.rbs +159 -134
  151. data/stdlib/objspace/0/objspace.rbs +8 -7
  152. data/stdlib/open-uri/0/open-uri.rbs +8 -8
  153. data/stdlib/open3/0/open3.rbs +36 -35
  154. data/stdlib/openssl/0/openssl.rbs +144 -129
  155. data/stdlib/optparse/0/optparse.rbs +18 -14
  156. data/stdlib/pathname/0/pathname.rbs +2 -2
  157. data/stdlib/pp/0/pp.rbs +9 -8
  158. data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
  159. data/stdlib/pstore/0/pstore.rbs +35 -30
  160. data/stdlib/psych/0/psych.rbs +61 -8
  161. data/stdlib/psych/0/store.rbs +2 -4
  162. data/stdlib/pty/0/pty.rbs +9 -6
  163. data/stdlib/random-formatter/0/random-formatter.rbs +2 -2
  164. data/stdlib/ripper/0/ripper.rbs +20 -17
  165. data/stdlib/securerandom/0/securerandom.rbs +1 -1
  166. data/stdlib/shellwords/0/shellwords.rbs +2 -2
  167. data/stdlib/socket/0/addrinfo.rbs +7 -7
  168. data/stdlib/socket/0/basic_socket.rbs +3 -3
  169. data/stdlib/socket/0/ip_socket.rbs +10 -8
  170. data/stdlib/socket/0/socket.rbs +10 -9
  171. data/stdlib/socket/0/tcp_server.rbs +1 -1
  172. data/stdlib/socket/0/tcp_socket.rbs +1 -1
  173. data/stdlib/socket/0/udp_socket.rbs +1 -1
  174. data/stdlib/socket/0/unix_server.rbs +1 -1
  175. data/stdlib/stringio/0/stringio.rbs +55 -54
  176. data/stdlib/strscan/0/string_scanner.rbs +46 -44
  177. data/stdlib/tempfile/0/tempfile.rbs +24 -20
  178. data/stdlib/time/0/time.rbs +7 -5
  179. data/stdlib/tsort/0/tsort.rbs +7 -6
  180. data/stdlib/uri/0/common.rbs +26 -18
  181. data/stdlib/uri/0/file.rbs +2 -2
  182. data/stdlib/uri/0/generic.rbs +2 -2
  183. data/stdlib/uri/0/http.rbs +2 -2
  184. data/stdlib/uri/0/ldap.rbs +2 -2
  185. data/stdlib/uri/0/mailto.rbs +3 -3
  186. data/stdlib/uri/0/rfc2396_parser.rbs +6 -5
  187. data/stdlib/zlib/0/deflate.rbs +4 -3
  188. data/stdlib/zlib/0/gzip_reader.rbs +4 -4
  189. data/stdlib/zlib/0/gzip_writer.rbs +14 -12
  190. data/stdlib/zlib/0/inflate.rbs +1 -1
  191. data/stdlib/zlib/0/need_dict.rbs +1 -1
  192. metadata +23 -5
  193. data/.github/workflows/valgrind.yml +0 -42
data/config.yml CHANGED
@@ -1,19 +1,25 @@
1
+ # See `docs/config.md` for quick documentation of this file format.
2
+
1
3
  nodes:
2
4
  - name: RBS::AST::Annotation
5
+ rust_name: AnnotationNode
3
6
  fields:
4
7
  - name: string
5
8
  c_type: rbs_string
6
9
  - name: RBS::AST::Bool
10
+ rust_name: BoolNode
7
11
  expose_to_ruby: false
8
12
  expose_location: false
9
13
  fields:
10
14
  - name: value
11
15
  c_type: bool
12
16
  - name: RBS::AST::Comment
17
+ rust_name: CommentNode
13
18
  fields:
14
19
  - name: string
15
20
  c_type: rbs_string
16
21
  - name: RBS::AST::Declarations::Class
22
+ rust_name: ClassNode
17
23
  fields:
18
24
  - name: name
19
25
  c_type: rbs_type_name
@@ -21,19 +27,32 @@ nodes:
21
27
  c_type: rbs_node_list
22
28
  - name: super_class
23
29
  c_type: rbs_ast_declarations_class_super
30
+ optional: true # NULL when no superclass (e.g., `class Foo end` vs `class Foo < Bar end`)
24
31
  - name: members
25
32
  c_type: rbs_node_list
26
33
  - name: annotations
27
34
  c_type: rbs_node_list
28
35
  - name: comment
29
36
  c_type: rbs_ast_comment
37
+ optional: true # NULL when no comment precedes the declaration
38
+ locations:
39
+ - required: keyword
40
+ - required: name
41
+ - required: end
42
+ - optional: type_params
43
+ - optional: lt
30
44
  - name: RBS::AST::Declarations::Class::Super
45
+ rust_name: ClassSuperNode
31
46
  fields:
32
47
  - name: name
33
48
  c_type: rbs_type_name
34
49
  - name: args
35
50
  c_type: rbs_node_list
51
+ locations:
52
+ - required: name
53
+ - optional: args
36
54
  - name: RBS::AST::Declarations::ClassAlias
55
+ rust_name: ClassAliasNode
37
56
  fields:
38
57
  - name: new_name
39
58
  c_type: rbs_type_name
@@ -41,9 +60,16 @@ nodes:
41
60
  c_type: rbs_type_name
42
61
  - name: comment
43
62
  c_type: rbs_ast_comment
63
+ optional: true # NULL when no comment precedes the declaration
44
64
  - name: annotations
45
65
  c_type: rbs_node_list
66
+ locations:
67
+ - required: keyword
68
+ - required: new_name
69
+ - required: eq
70
+ - required: old_name
46
71
  - name: RBS::AST::Declarations::Constant
72
+ rust_name: ConstantNode
47
73
  fields:
48
74
  - name: name
49
75
  c_type: rbs_type_name
@@ -51,9 +77,14 @@ nodes:
51
77
  c_type: rbs_node
52
78
  - name: comment
53
79
  c_type: rbs_ast_comment
80
+ optional: true # NULL when no comment precedes the declaration
54
81
  - name: annotations
55
82
  c_type: rbs_node_list
83
+ locations:
84
+ - required: name
85
+ - required: colon
56
86
  - name: RBS::AST::Declarations::Global
87
+ rust_name: GlobalNode
57
88
  fields:
58
89
  - name: name
59
90
  c_type: rbs_ast_symbol
@@ -61,9 +92,14 @@ nodes:
61
92
  c_type: rbs_node
62
93
  - name: comment
63
94
  c_type: rbs_ast_comment
95
+ optional: true # NULL when no comment precedes the declaration
64
96
  - name: annotations
65
97
  c_type: rbs_node_list
98
+ locations:
99
+ - required: name
100
+ - required: colon
66
101
  - name: RBS::AST::Declarations::Interface
102
+ rust_name: InterfaceNode
67
103
  fields:
68
104
  - name: name
69
105
  c_type: rbs_type_name
@@ -75,7 +111,14 @@ nodes:
75
111
  c_type: rbs_node_list
76
112
  - name: comment
77
113
  c_type: rbs_ast_comment
114
+ optional: true # NULL when no comment precedes the declaration
115
+ locations:
116
+ - required: keyword
117
+ - required: name
118
+ - required: end
119
+ - optional: type_params
78
120
  - name: RBS::AST::Declarations::Module
121
+ rust_name: ModuleNode
79
122
  fields:
80
123
  - name: name
81
124
  c_type: rbs_type_name
@@ -89,13 +132,26 @@ nodes:
89
132
  c_type: rbs_node_list
90
133
  - name: comment
91
134
  c_type: rbs_ast_comment
135
+ optional: true # NULL when no comment precedes the declaration
136
+ locations:
137
+ - required: keyword
138
+ - required: name
139
+ - required: end
140
+ - optional: type_params
141
+ - optional: colon
142
+ - optional: self_types
92
143
  - name: RBS::AST::Declarations::Module::Self
144
+ rust_name: ModuleSelfNode
93
145
  fields:
94
146
  - name: name
95
147
  c_type: rbs_type_name
96
148
  - name: args
97
149
  c_type: rbs_node_list
150
+ locations:
151
+ - required: name
152
+ - optional: args
98
153
  - name: RBS::AST::Declarations::ModuleAlias
154
+ rust_name: ModuleAliasNode
99
155
  fields:
100
156
  - name: new_name
101
157
  c_type: rbs_type_name
@@ -103,9 +159,16 @@ nodes:
103
159
  c_type: rbs_type_name
104
160
  - name: comment
105
161
  c_type: rbs_ast_comment
162
+ optional: true # NULL when no comment precedes the declaration
106
163
  - name: annotations
107
164
  c_type: rbs_node_list
165
+ locations:
166
+ - required: keyword
167
+ - required: new_name
168
+ - required: eq
169
+ - required: old_name
108
170
  - name: RBS::AST::Declarations::TypeAlias
171
+ rust_name: TypeAliasNode
109
172
  fields:
110
173
  - name: name
111
174
  c_type: rbs_type_name
@@ -117,82 +180,140 @@ nodes:
117
180
  c_type: rbs_node_list
118
181
  - name: comment
119
182
  c_type: rbs_ast_comment
183
+ optional: true # NULL when no comment precedes the declaration
184
+ locations:
185
+ - required: keyword
186
+ - required: name
187
+ - required: eq
188
+ - optional: type_params
120
189
  - name: RBS::AST::Directives::Use
190
+ rust_name: UseNode
121
191
  fields:
122
192
  - name: clauses
123
193
  c_type: rbs_node_list
194
+ locations:
195
+ - required: keyword
124
196
  - name: RBS::AST::Directives::Use::SingleClause
197
+ rust_name: UseSingleClauseNode
125
198
  fields:
126
199
  - name: type_name
127
200
  c_type: rbs_type_name
128
201
  - name: new_name
129
202
  c_type: rbs_ast_symbol
203
+ optional: true # NULL when no alias (e.g., `use Foo::Bar` vs `use Foo::Bar as Baz`)
204
+ locations:
205
+ - required: type_name
206
+ - optional: keyword
207
+ - optional: new_name
130
208
  - name: RBS::AST::Directives::Use::WildcardClause
209
+ rust_name: UseWildcardClauseNode
131
210
  fields:
132
211
  - name: namespace
133
212
  c_type: rbs_namespace
134
213
  c_name: rbs_namespace
214
+ locations:
215
+ - required: namespace
216
+ - required: star
135
217
  - name: RBS::AST::Members::Alias
218
+ rust_name: AliasNode
136
219
  fields:
137
220
  - name: new_name
138
221
  c_type: rbs_ast_symbol
139
222
  - name: old_name
140
223
  c_type: rbs_ast_symbol
141
224
  - name: kind
142
- c_type: rbs_keyword
225
+ c_type: alias_kind
143
226
  - name: annotations
144
227
  c_type: rbs_node_list
145
228
  - name: comment
146
229
  c_type: rbs_ast_comment
230
+ optional: true # NULL when no comment precedes the declaration
231
+ locations:
232
+ - required: keyword
233
+ - required: new_name
234
+ - required: old_name
235
+ - optional: new_kind
236
+ - optional: old_kind
147
237
  - name: RBS::AST::Members::AttrAccessor
238
+ rust_name: AttrAccessorNode
148
239
  fields:
149
240
  - name: name
150
241
  c_type: rbs_ast_symbol
151
242
  - name: type
152
243
  c_type: rbs_node
153
244
  - name: ivar_name
154
- c_type: rbs_node # rbs_ast_symbol_t, NULL or rbs_ast_bool_new(false)
245
+ c_type: rbs_attr_ivar_name
155
246
  - name: kind
156
- c_type: rbs_keyword
247
+ c_type: attribute_kind
157
248
  - name: annotations
158
249
  c_type: rbs_node_list
159
250
  - name: comment
160
251
  c_type: rbs_ast_comment
252
+ optional: true # NULL when no comment precedes the declaration
161
253
  - name: visibility
162
- c_type: rbs_keyword
254
+ c_type: attribute_visibility
255
+ locations:
256
+ - required: keyword
257
+ - required: name
258
+ - required: colon
259
+ - optional: kind
260
+ - optional: ivar
261
+ - optional: ivar_name
262
+ - optional: visibility
163
263
  - name: RBS::AST::Members::AttrReader
264
+ rust_name: AttrReaderNode
164
265
  fields:
165
266
  - name: name
166
267
  c_type: rbs_ast_symbol
167
268
  - name: type
168
269
  c_type: rbs_node
169
270
  - name: ivar_name
170
- c_type: rbs_node # rbs_ast_symbol_t, NULL or rbs_ast_bool_new(false)
271
+ c_type: rbs_attr_ivar_name
171
272
  - name: kind
172
- c_type: rbs_keyword
273
+ c_type: attribute_kind
173
274
  - name: annotations
174
275
  c_type: rbs_node_list
175
276
  - name: comment
176
277
  c_type: rbs_ast_comment
278
+ optional: true # NULL when no comment precedes the declaration
177
279
  - name: visibility
178
- c_type: rbs_keyword
280
+ c_type: attribute_visibility
281
+ locations:
282
+ - required: keyword
283
+ - required: name
284
+ - required: colon
285
+ - optional: kind
286
+ - optional: ivar
287
+ - optional: ivar_name
288
+ - optional: visibility
179
289
  - name: RBS::AST::Members::AttrWriter
290
+ rust_name: AttrWriterNode
180
291
  fields:
181
292
  - name: name
182
293
  c_type: rbs_ast_symbol
183
294
  - name: type
184
295
  c_type: rbs_node
185
296
  - name: ivar_name
186
- c_type: rbs_node # rbs_ast_symbol_t, NULL or rbs_ast_bool_new(false)
297
+ c_type: rbs_attr_ivar_name
187
298
  - name: kind
188
- c_type: rbs_keyword
299
+ c_type: attribute_kind
189
300
  - name: annotations
190
301
  c_type: rbs_node_list
191
302
  - name: comment
192
303
  c_type: rbs_ast_comment
304
+ optional: true # NULL when no comment precedes the declaration
193
305
  - name: visibility
194
- c_type: rbs_keyword
306
+ c_type: attribute_visibility
307
+ locations:
308
+ - required: keyword
309
+ - required: name
310
+ - required: colon
311
+ - optional: kind
312
+ - optional: ivar
313
+ - optional: ivar_name
314
+ - optional: visibility
195
315
  - name: RBS::AST::Members::ClassInstanceVariable
316
+ rust_name: ClassInstanceVariableNode
196
317
  fields:
197
318
  - name: name
198
319
  c_type: rbs_ast_symbol
@@ -200,7 +321,13 @@ nodes:
200
321
  c_type: rbs_node
201
322
  - name: comment
202
323
  c_type: rbs_ast_comment
324
+ optional: true # NULL when no comment precedes the declaration
325
+ locations:
326
+ - required: name
327
+ - required: colon
328
+ - optional: kind
203
329
  - name: RBS::AST::Members::ClassVariable
330
+ rust_name: ClassVariableNode
204
331
  fields:
205
332
  - name: name
206
333
  c_type: rbs_ast_symbol
@@ -208,7 +335,13 @@ nodes:
208
335
  c_type: rbs_node
209
336
  - name: comment
210
337
  c_type: rbs_ast_comment
338
+ optional: true # NULL when no comment precedes the declaration
339
+ locations:
340
+ - required: name
341
+ - required: colon
342
+ - optional: kind
211
343
  - name: RBS::AST::Members::Extend
344
+ rust_name: ExtendNode
212
345
  fields:
213
346
  - name: name
214
347
  c_type: rbs_type_name
@@ -218,7 +351,13 @@ nodes:
218
351
  c_type: rbs_node_list
219
352
  - name: comment
220
353
  c_type: rbs_ast_comment
354
+ optional: true # NULL when no comment precedes the declaration
355
+ locations:
356
+ - required: name
357
+ - required: keyword
358
+ - optional: args
221
359
  - name: RBS::AST::Members::Include
360
+ rust_name: IncludeNode
222
361
  fields:
223
362
  - name: name
224
363
  c_type: rbs_type_name
@@ -228,7 +367,13 @@ nodes:
228
367
  c_type: rbs_node_list
229
368
  - name: comment
230
369
  c_type: rbs_ast_comment
370
+ optional: true # NULL when no comment precedes the declaration
371
+ locations:
372
+ - required: name
373
+ - required: keyword
374
+ - optional: args
231
375
  - name: RBS::AST::Members::InstanceVariable
376
+ rust_name: InstanceVariableNode
232
377
  fields:
233
378
  - name: name
234
379
  c_type: rbs_ast_symbol
@@ -236,23 +381,37 @@ nodes:
236
381
  c_type: rbs_node
237
382
  - name: comment
238
383
  c_type: rbs_ast_comment
384
+ optional: true # NULL when no comment precedes the declaration
385
+ locations:
386
+ - required: name
387
+ - required: colon
388
+ - optional: kind
239
389
  - name: RBS::AST::Members::MethodDefinition
390
+ rust_name: MethodDefinitionNode
240
391
  fields:
241
392
  - name: name
242
393
  c_type: rbs_ast_symbol
243
394
  - name: kind
244
- c_type: rbs_keyword
395
+ c_type: method_definition_kind
245
396
  - name: overloads
246
397
  c_type: rbs_node_list
247
398
  - name: annotations
248
399
  c_type: rbs_node_list
249
400
  - name: comment
250
401
  c_type: rbs_ast_comment
402
+ optional: true # NULL when no comment precedes the declaration
251
403
  - name: overloading
252
404
  c_type: bool
253
405
  - name: visibility
254
- c_type: rbs_keyword
406
+ c_type: method_definition_visibility
407
+ locations:
408
+ - required: keyword
409
+ - required: name
410
+ - optional: kind
411
+ - optional: overloading
412
+ - optional: visibility
255
413
  - name: RBS::AST::Members::MethodDefinition::Overload
414
+ rust_name: MethodDefinitionOverloadNode
256
415
  expose_location: false
257
416
  fields:
258
417
  - name: annotations
@@ -260,6 +419,7 @@ nodes:
260
419
  - name: method_type
261
420
  c_type: rbs_node
262
421
  - name: RBS::AST::Members::Prepend
422
+ rust_name: PrependNode
263
423
  fields:
264
424
  - name: name
265
425
  c_type: rbs_type_name
@@ -269,35 +429,56 @@ nodes:
269
429
  c_type: rbs_node_list
270
430
  - name: comment
271
431
  c_type: rbs_ast_comment
432
+ optional: true # NULL when no comment precedes the declaration
433
+ locations:
434
+ - required: name
435
+ - required: keyword
436
+ - optional: args
272
437
  - name: RBS::AST::Members::Private
438
+ rust_name: PrivateNode
273
439
  - name: RBS::AST::Members::Public
440
+ rust_name: PublicNode
274
441
  - name: RBS::AST::TypeParam
442
+ rust_name: TypeParamNode
275
443
  fields:
276
444
  - name: name
277
445
  c_type: rbs_ast_symbol
278
446
  - name: variance
279
- c_type: rbs_keyword
447
+ c_type: type_param_variance
280
448
  - name: upper_bound
281
449
  c_type: rbs_node
450
+ optional: true # NULL when no upper bound (e.g., `[T]` vs `[T < Bound]`)
282
451
  - name: lower_bound
283
452
  c_type: rbs_node
453
+ optional: true # NULL when no lower bound (e.g., `[T]` vs `[T > Bound]`)
284
454
  - name: default_type
285
455
  c_type: rbs_node
456
+ optional: true # NULL when no default (e.g., `[T]` vs `[T = Default]`)
286
457
  - name: unchecked
287
458
  c_type: bool
459
+ locations:
460
+ - required: name
461
+ - optional: variance
462
+ - optional: unchecked
463
+ - optional: upper_bound
464
+ - optional: lower_bound
465
+ - optional: default
288
466
  - name: RBS::AST::Integer
467
+ rust_name: IntegerNode
289
468
  expose_to_ruby: false
290
469
  expose_location: false
291
470
  fields:
292
471
  - name: string_representation
293
472
  c_type: rbs_string
294
473
  - name: RBS::AST::String
474
+ rust_name: StringNode
295
475
  expose_to_ruby: false
296
476
  expose_location: false
297
477
  fields:
298
478
  - name: string
299
479
  c_type: rbs_string
300
480
  - name: RBS::MethodType
481
+ rust_name: MethodTypeNode
301
482
  fields:
302
483
  - name: type_params
303
484
  c_type: rbs_node_list
@@ -305,7 +486,12 @@ nodes:
305
486
  c_type: rbs_node
306
487
  - name: block
307
488
  c_type: rbs_types_block
489
+ optional: true # NULL when no block (e.g., `() -> void` vs `() { () -> void } -> void`)
490
+ locations:
491
+ - required: type
492
+ - optional: type_params
308
493
  - name: RBS::Namespace
494
+ rust_name: NamespaceNode
309
495
  expose_location: false
310
496
  fields:
311
497
  - name: path
@@ -313,6 +499,7 @@ nodes:
313
499
  - name: absolute
314
500
  c_type: bool
315
501
  - name: RBS::Signature
502
+ rust_name: SignatureNode
316
503
  expose_to_ruby: false
317
504
  expose_location: false
318
505
  fields:
@@ -321,6 +508,7 @@ nodes:
321
508
  - name: declarations
322
509
  c_type: rbs_node_list
323
510
  - name: RBS::TypeName
511
+ rust_name: TypeNameNode
324
512
  expose_location: false
325
513
  fields:
326
514
  - name: namespace
@@ -329,24 +517,38 @@ nodes:
329
517
  - name: name
330
518
  c_type: rbs_ast_symbol
331
519
  - name: RBS::Types::Alias
520
+ rust_name: AliasTypeNode
332
521
  fields:
333
522
  - name: name
334
523
  c_type: rbs_type_name
335
524
  - name: args
336
525
  c_type: rbs_node_list
526
+ locations:
527
+ - required: name
528
+ - optional: args
337
529
  - name: RBS::Types::Bases::Any
530
+ rust_name: AnyTypeNode
338
531
  fields:
339
532
  - name: todo
340
533
  c_type: bool
341
534
  - name: RBS::Types::Bases::Bool
535
+ rust_name: BoolTypeNode
342
536
  - name: RBS::Types::Bases::Bottom
537
+ rust_name: BottomTypeNode
343
538
  - name: RBS::Types::Bases::Class
539
+ rust_name: ClassTypeNode
344
540
  - name: RBS::Types::Bases::Instance
541
+ rust_name: InstanceTypeNode
345
542
  - name: RBS::Types::Bases::Nil
543
+ rust_name: NilTypeNode
346
544
  - name: RBS::Types::Bases::Self
545
+ rust_name: SelfTypeNode
347
546
  - name: RBS::Types::Bases::Top
547
+ rust_name: TopTypeNode
348
548
  - name: RBS::Types::Bases::Void
549
+ rust_name: VoidTypeNode
349
550
  - name: RBS::Types::Block
551
+ rust_name: BlockTypeNode
350
552
  expose_location: true
351
553
  fields:
352
554
  - name: type
@@ -355,17 +557,29 @@ nodes:
355
557
  c_type: bool
356
558
  - name: self_type
357
559
  c_type: rbs_node
560
+ optional: true # NULL when no self binding (e.g., `{ () -> void }` vs `{ () [self: T] -> void }`)
358
561
  - name: RBS::Types::ClassInstance
562
+ rust_name: ClassInstanceTypeNode
359
563
  fields:
360
564
  - name: name
361
565
  c_type: rbs_type_name
362
566
  - name: args
363
567
  c_type: rbs_node_list
568
+ locations:
569
+ - required: name
570
+ - optional: args
364
571
  - name: RBS::Types::ClassSingleton
572
+ rust_name: ClassSingletonTypeNode
365
573
  fields:
366
574
  - name: name
367
575
  c_type: rbs_type_name
576
+ - name: args
577
+ c_type: rbs_node_list
578
+ locations:
579
+ - required: name
580
+ - optional: args
368
581
  - name: RBS::Types::Function
582
+ rust_name: FunctionTypeNode
369
583
  expose_location: false
370
584
  fields:
371
585
  - name: required_positionals
@@ -374,6 +588,7 @@ nodes:
374
588
  c_type: rbs_node_list
375
589
  - name: rest_positionals
376
590
  c_type: rbs_node
591
+ optional: true # NULL when no splat (e.g., `(String) -> void` vs `(*String) -> void`)
377
592
  - name: trailing_positionals
378
593
  c_type: rbs_node_list
379
594
  - name: required_keywords
@@ -382,45 +597,62 @@ nodes:
382
597
  c_type: rbs_hash
383
598
  - name: rest_keywords
384
599
  c_type: rbs_node
600
+ optional: true # NULL when no double-splat (e.g., `() -> void` vs `(**String) -> void`)
385
601
  - name: return_type
386
602
  c_type: rbs_node
387
603
  - name: RBS::Types::Function::Param
604
+ rust_name: FunctionParamNode
388
605
  fields:
389
606
  - name: type
390
607
  c_type: rbs_node
391
608
  - name: name
392
609
  c_type: rbs_ast_symbol
610
+ optional: true # NULL when param is unnamed (e.g., `(String) -> void` vs `(String name) -> void`)
611
+ locations:
612
+ - optional: name
393
613
  - name: RBS::Types::Interface
614
+ rust_name: InterfaceTypeNode
394
615
  fields:
395
616
  - name: name
396
617
  c_type: rbs_type_name
397
618
  - name: args
398
619
  c_type: rbs_node_list
620
+ locations:
621
+ - required: name
622
+ - optional: args
399
623
  - name: RBS::Types::Intersection
624
+ rust_name: IntersectionTypeNode
400
625
  fields:
401
626
  - name: types
402
627
  c_type: rbs_node_list
403
628
  - name: RBS::Types::Literal
629
+ rust_name: LiteralTypeNode
404
630
  fields:
405
631
  - name: literal
406
632
  c_type: rbs_node
407
633
  - name: RBS::Types::Optional
634
+ rust_name: OptionalTypeNode
408
635
  fields:
409
636
  - name: type
410
637
  c_type: rbs_node
411
638
  - name: RBS::Types::Proc
639
+ rust_name: ProcTypeNode
412
640
  fields:
413
641
  - name: type
414
642
  c_type: rbs_node
415
643
  - name: block
416
644
  c_type: rbs_types_block
645
+ optional: true # NULL when proc has no block (e.g., `^() -> void` vs `^() { () -> void } -> void`)
417
646
  - name: self_type
418
647
  c_type: rbs_node
648
+ optional: true # NULL when no self binding (e.g., `^() -> void` vs `^() [self: T] -> void`)
419
649
  - name: RBS::Types::Record
650
+ rust_name: RecordTypeNode
420
651
  fields:
421
652
  - name: all_fields
422
653
  c_type: rbs_hash
423
654
  - name: RBS::Types::Record::FieldType
655
+ rust_name: RecordFieldTypeNode
424
656
  expose_to_ruby: false
425
657
  expose_location: false
426
658
  fields:
@@ -429,105 +661,229 @@ nodes:
429
661
  - name: required
430
662
  c_type: bool
431
663
  - name: RBS::Types::Tuple
664
+ rust_name: TupleTypeNode
432
665
  fields:
433
666
  - name: types
434
667
  c_type: rbs_node_list
435
668
  - name: RBS::Types::Union
669
+ rust_name: UnionTypeNode
436
670
  fields:
437
671
  - name: types
438
672
  c_type: rbs_node_list
439
673
  - name: RBS::Types::UntypedFunction
674
+ rust_name: UntypedFunctionTypeNode
440
675
  expose_location: false
441
676
  fields:
442
677
  - name: return_type
443
678
  c_type: rbs_node
444
679
  - name: RBS::Types::Variable
680
+ rust_name: VariableTypeNode
445
681
  fields:
446
682
  - name: name
447
683
  c_type: rbs_ast_symbol
448
684
  - name: RBS::AST::Ruby::Annotations::NodeTypeAssertion
685
+ rust_name: NodeTypeAssertionNode
449
686
  fields:
450
687
  - name: prefix_location
451
- c_type: rbs_location
688
+ c_type: rbs_location_range
452
689
  - name: type
453
690
  c_type: rbs_node
454
691
  - name: RBS::AST::Ruby::Annotations::ColonMethodTypeAnnotation
692
+ rust_name: ColonMethodTypeAnnotationNode
455
693
  fields:
456
694
  - name: prefix_location
457
- c_type: rbs_location
695
+ c_type: rbs_location_range
458
696
  - name: annotations
459
697
  c_type: rbs_node_list
460
698
  - name: method_type
461
699
  c_type: rbs_node
462
700
  - name: RBS::AST::Ruby::Annotations::MethodTypesAnnotation
701
+ rust_name: MethodTypesAnnotationNode
463
702
  fields:
464
703
  - name: prefix_location
465
- c_type: rbs_location
704
+ c_type: rbs_location_range
466
705
  - name: overloads
467
706
  c_type: rbs_node_list
468
707
  - name: vertical_bar_locations
469
- c_type: rbs_location_list
708
+ c_type: rbs_location_range_list
709
+ - name: dot3_location
710
+ c_type: rbs_location_range
711
+ optional: true
470
712
  - name: RBS::AST::Ruby::Annotations::SkipAnnotation
713
+ rust_name: SkipAnnotationNode
471
714
  fields:
472
715
  - name: prefix_location
473
- c_type: rbs_location
716
+ c_type: rbs_location_range
474
717
  - name: skip_location
475
- c_type: rbs_location
718
+ c_type: rbs_location_range
476
719
  - name: comment_location
477
- c_type: rbs_location
720
+ c_type: rbs_location_range
721
+ optional: true
478
722
  - name: RBS::AST::Ruby::Annotations::ReturnTypeAnnotation
723
+ rust_name: ReturnTypeAnnotationNode
479
724
  fields:
480
725
  - name: prefix_location
481
- c_type: rbs_location
726
+ c_type: rbs_location_range
482
727
  - name: return_location
483
- c_type: rbs_location
728
+ c_type: rbs_location_range
484
729
  - name: colon_location
485
- c_type: rbs_location
730
+ c_type: rbs_location_range
486
731
  - name: return_type
487
732
  c_type: rbs_node
488
733
  - name: comment_location
489
- c_type: rbs_location
734
+ c_type: rbs_location_range
735
+ optional: true
490
736
  - name: RBS::AST::Ruby::Annotations::TypeApplicationAnnotation
737
+ rust_name: TypeApplicationAnnotationNode
491
738
  fields:
492
739
  - name: prefix_location
493
- c_type: rbs_location
740
+ c_type: rbs_location_range
494
741
  - name: type_args
495
742
  c_type: rbs_node_list
496
743
  - name: close_bracket_location
497
- c_type: rbs_location
744
+ c_type: rbs_location_range
498
745
  - name: comma_locations
499
- c_type: rbs_location_list
746
+ c_type: rbs_location_range_list
500
747
  - name: RBS::AST::Ruby::Annotations::InstanceVariableAnnotation
748
+ rust_name: InstanceVariableAnnotationNode
501
749
  fields:
502
750
  - name: prefix_location
503
- c_type: rbs_location
751
+ c_type: rbs_location_range
504
752
  - name: ivar_name
505
753
  c_type: rbs_ast_symbol
506
754
  - name: ivar_name_location
507
- c_type: rbs_location
755
+ c_type: rbs_location_range
508
756
  - name: colon_location
509
- c_type: rbs_location
757
+ c_type: rbs_location_range
510
758
  - name: type
511
759
  c_type: rbs_node
512
760
  - name: comment_location
513
- c_type: rbs_location
761
+ c_type: rbs_location_range
762
+ optional: true
514
763
  - name: RBS::AST::Ruby::Annotations::ClassAliasAnnotation
764
+ rust_name: ClassAliasAnnotationNode
515
765
  fields:
516
766
  - name: prefix_location
517
- c_type: rbs_location
767
+ c_type: rbs_location_range
518
768
  - name: keyword_location
519
- c_type: rbs_location
769
+ c_type: rbs_location_range
520
770
  - name: type_name
521
771
  c_type: rbs_type_name
522
772
  - name: type_name_location
523
- c_type: rbs_location
773
+ c_type: rbs_location_range
774
+ optional: true
524
775
  - name: RBS::AST::Ruby::Annotations::ModuleAliasAnnotation
776
+ rust_name: ModuleAliasAnnotationNode
525
777
  fields:
526
778
  - name: prefix_location
527
- c_type: rbs_location
779
+ c_type: rbs_location_range
528
780
  - name: keyword_location
529
- c_type: rbs_location
781
+ c_type: rbs_location_range
530
782
  - name: type_name
531
783
  c_type: rbs_type_name
532
784
  - name: type_name_location
533
- c_type: rbs_location
785
+ c_type: rbs_location_range
786
+ optional: true
787
+ - name: RBS::AST::Ruby::Annotations::ParamTypeAnnotation
788
+ rust_name: ParamTypeAnnotationNode
789
+ fields:
790
+ - name: prefix_location
791
+ c_type: rbs_location_range
792
+ - name: name_location
793
+ c_type: rbs_location_range
794
+ - name: colon_location
795
+ c_type: rbs_location_range
796
+ - name: param_type
797
+ c_type: rbs_node
798
+ - name: comment_location
799
+ c_type: rbs_location_range
800
+ optional: true
801
+ - name: RBS::AST::Ruby::Annotations::SplatParamTypeAnnotation
802
+ rust_name: SplatParamTypeAnnotationNode
803
+ fields:
804
+ - name: prefix_location
805
+ c_type: rbs_location_range
806
+ - name: star_location
807
+ c_type: rbs_location_range
808
+ - name: name_location
809
+ c_type: rbs_location_range
810
+ optional: true
811
+ - name: colon_location
812
+ c_type: rbs_location_range
813
+ - name: param_type
814
+ c_type: rbs_node
815
+ - name: comment_location
816
+ c_type: rbs_location_range
817
+ optional: true
818
+ - name: RBS::AST::Ruby::Annotations::DoubleSplatParamTypeAnnotation
819
+ rust_name: DoubleSplatParamTypeAnnotationNode
820
+ fields:
821
+ - name: prefix_location
822
+ c_type: rbs_location_range
823
+ - name: star2_location
824
+ c_type: rbs_location_range
825
+ - name: name_location
826
+ c_type: rbs_location_range
827
+ optional: true
828
+ - name: colon_location
829
+ c_type: rbs_location_range
830
+ - name: param_type
831
+ c_type: rbs_node
832
+ - name: comment_location
833
+ c_type: rbs_location_range
834
+ optional: true
835
+ - name: RBS::AST::Ruby::Annotations::BlockParamTypeAnnotation
836
+ rust_name: BlockParamTypeAnnotationNode
837
+ fields:
838
+ - name: prefix_location
839
+ c_type: rbs_location_range
840
+ - name: ampersand_location
841
+ c_type: rbs_location_range
842
+ - name: name_location
843
+ c_type: rbs_location_range
844
+ optional: true
845
+ - name: colon_location
846
+ c_type: rbs_location_range
847
+ - name: question_location
848
+ c_type: rbs_location_range
849
+ optional: true
850
+ - name: type_location
851
+ c_type: rbs_location_range
852
+ - name: type
853
+ c_name: type_
854
+ c_type: rbs_node
855
+ - name: comment_location
856
+ c_type: rbs_location_range
857
+ optional: true
858
+
859
+ enums:
860
+ attribute_visibility:
861
+ optional: true
862
+ symbols:
863
+ - unspecified
864
+ - public
865
+ - private
866
+ attribute_kind:
867
+ symbols:
868
+ - instance
869
+ - singleton
870
+ alias_kind:
871
+ symbols:
872
+ - instance
873
+ - singleton
874
+ method_definition_kind:
875
+ symbols:
876
+ - instance
877
+ - singleton
878
+ - singleton_instance
879
+ method_definition_visibility:
880
+ optional: true
881
+ symbols:
882
+ - unspecified
883
+ - public
884
+ - private
885
+ type_param_variance:
886
+ symbols:
887
+ - invariant
888
+ - covariant
889
+ - contravariant