rbs 0.3.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +7 -1
- data/.gitignore +1 -1
- data/CHANGELOG.md +39 -0
- data/COPYING +1 -1
- data/Gemfile +16 -2
- data/README.md +87 -48
- data/Rakefile +54 -22
- data/bin/rbs-prof +9 -0
- data/bin/run_in_md.rb +49 -0
- data/bin/test_runner.rb +0 -2
- data/docs/sigs.md +6 -6
- data/docs/stdlib.md +3 -5
- data/docs/syntax.md +6 -3
- data/goodcheck.yml +65 -0
- data/lib/rbs.rb +3 -0
- data/lib/rbs/ast/declarations.rb +115 -14
- data/lib/rbs/ast/members.rb +41 -17
- data/lib/rbs/cli.rb +315 -122
- data/lib/rbs/constant.rb +4 -4
- data/lib/rbs/constant_table.rb +51 -45
- data/lib/rbs/definition.rb +175 -59
- data/lib/rbs/definition_builder.rb +802 -604
- data/lib/rbs/environment.rb +352 -210
- data/lib/rbs/environment_walker.rb +14 -23
- data/lib/rbs/errors.rb +184 -3
- data/lib/rbs/factory.rb +14 -0
- data/lib/rbs/parser.y +95 -27
- data/lib/rbs/prototype/rb.rb +119 -117
- data/lib/rbs/prototype/rbi.rb +5 -3
- data/lib/rbs/prototype/runtime.rb +34 -7
- data/lib/rbs/substitution.rb +12 -1
- data/lib/rbs/test.rb +82 -3
- data/lib/rbs/test/errors.rb +5 -1
- data/lib/rbs/test/hook.rb +133 -259
- data/lib/rbs/test/observer.rb +17 -0
- data/lib/rbs/test/setup.rb +35 -19
- data/lib/rbs/test/setup_helper.rb +29 -0
- data/lib/rbs/test/spy.rb +0 -321
- data/lib/rbs/test/tester.rb +116 -0
- data/lib/rbs/test/type_check.rb +43 -7
- data/lib/rbs/type_name_resolver.rb +58 -0
- data/lib/rbs/types.rb +94 -2
- data/lib/rbs/validator.rb +51 -0
- data/lib/rbs/variance_calculator.rb +12 -2
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +127 -91
- data/rbs.gemspec +0 -9
- data/schema/annotation.json +14 -0
- data/schema/comment.json +26 -0
- data/schema/decls.json +353 -0
- data/schema/function.json +87 -0
- data/schema/location.json +56 -0
- data/schema/members.json +248 -0
- data/schema/methodType.json +44 -0
- data/schema/types.json +299 -0
- data/stdlib/benchmark/benchmark.rbs +151 -151
- data/stdlib/builtin/encoding.rbs +2 -0
- data/stdlib/builtin/enumerable.rbs +4 -4
- data/stdlib/builtin/enumerator.rbs +3 -1
- data/stdlib/builtin/fiber.rbs +5 -1
- data/stdlib/builtin/file.rbs +0 -3
- data/stdlib/builtin/io.rbs +4 -4
- data/stdlib/builtin/proc.rbs +1 -2
- data/stdlib/builtin/symbol.rbs +1 -1
- data/stdlib/builtin/thread.rbs +2 -2
- data/stdlib/csv/csv.rbs +4 -6
- data/stdlib/fiber/fiber.rbs +117 -0
- data/stdlib/json/json.rbs +1 -1
- data/stdlib/logger/formatter.rbs +23 -0
- data/stdlib/logger/log_device.rbs +39 -0
- data/stdlib/logger/logger.rbs +507 -0
- data/stdlib/logger/period.rbs +7 -0
- data/stdlib/logger/severity.rbs +8 -0
- data/stdlib/mutex_m/mutex_m.rbs +77 -0
- data/stdlib/pathname/pathname.rbs +6 -6
- data/stdlib/prime/integer-extension.rbs +1 -1
- data/stdlib/prime/prime.rbs +44 -44
- data/stdlib/pty/pty.rbs +159 -0
- data/stdlib/tmpdir/tmpdir.rbs +1 -1
- metadata +28 -116
- data/lib/rbs/test/test_helper.rb +0 -183
data/schema/decls.json
ADDED
@@ -0,0 +1,353 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
3
|
+
"definitions": {
|
4
|
+
"alias": {
|
5
|
+
"title": "Type alias declaration: `type foo = Integer`, ...",
|
6
|
+
"type": "object",
|
7
|
+
"properties": {
|
8
|
+
"declaration": {
|
9
|
+
"type": "string",
|
10
|
+
"enum": ["alias"]
|
11
|
+
},
|
12
|
+
"name": {
|
13
|
+
"type": "string"
|
14
|
+
},
|
15
|
+
"type": {
|
16
|
+
"$ref": "types.json"
|
17
|
+
},
|
18
|
+
"annotations": {
|
19
|
+
"type": "array",
|
20
|
+
"items": {
|
21
|
+
"$ref": "annotation.json"
|
22
|
+
}
|
23
|
+
},
|
24
|
+
"location": {
|
25
|
+
"$ref": "location.json"
|
26
|
+
},
|
27
|
+
"comment": {
|
28
|
+
"$ref": "comment.json"
|
29
|
+
}
|
30
|
+
},
|
31
|
+
"required": ["declaration", "name", "type", "annotations", "location", "comment"]
|
32
|
+
},
|
33
|
+
"constant": {
|
34
|
+
"title": "Constant declaration: `VERSION: String`, ...",
|
35
|
+
"type": "object",
|
36
|
+
"properties": {
|
37
|
+
"declaration": {
|
38
|
+
"type": "string",
|
39
|
+
"enum": ["constant"]
|
40
|
+
},
|
41
|
+
"name": {
|
42
|
+
"type": "string"
|
43
|
+
},
|
44
|
+
"type": {
|
45
|
+
"$ref": "types.json"
|
46
|
+
},
|
47
|
+
"location": {
|
48
|
+
"$ref": "location.json"
|
49
|
+
},
|
50
|
+
"comment": {
|
51
|
+
"$ref": "comment.json"
|
52
|
+
}
|
53
|
+
},
|
54
|
+
"required": ["declaration", "name", "type", "comment", "location"]
|
55
|
+
},
|
56
|
+
"global": {
|
57
|
+
"title": "Global declaration: `$DEBUG: bool`, ...",
|
58
|
+
"type": "object",
|
59
|
+
"properties": {
|
60
|
+
"declaration": {
|
61
|
+
"type": "string",
|
62
|
+
"enum": ["global"]
|
63
|
+
},
|
64
|
+
"name": {
|
65
|
+
"type": "string"
|
66
|
+
},
|
67
|
+
"type": {
|
68
|
+
"$ref": "types.json"
|
69
|
+
},
|
70
|
+
"location": {
|
71
|
+
"$ref": "location.json"
|
72
|
+
},
|
73
|
+
"comment": {
|
74
|
+
"$ref": "comment.json"
|
75
|
+
}
|
76
|
+
},
|
77
|
+
"required": ["declaration", "name", "type", "comment", "location"]
|
78
|
+
},
|
79
|
+
"moduleTypeParam": {
|
80
|
+
"type": "object",
|
81
|
+
"properties": {
|
82
|
+
"name": {
|
83
|
+
"type": "string"
|
84
|
+
},
|
85
|
+
"variance": {
|
86
|
+
"enum": ["covariant", "contravariant", "invariant"]
|
87
|
+
},
|
88
|
+
"skip_validation": {
|
89
|
+
"type": "boolean"
|
90
|
+
}
|
91
|
+
},
|
92
|
+
"required": ["name", "variance", "skip_validation"]
|
93
|
+
},
|
94
|
+
"classMember": {
|
95
|
+
"oneOf": [
|
96
|
+
{
|
97
|
+
"$ref": "members.json#/definitions/methodDefinition"
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"$ref": "members.json#/definitions/variable"
|
101
|
+
},
|
102
|
+
{
|
103
|
+
"$ref": "members.json#/definitions/include"
|
104
|
+
},
|
105
|
+
{
|
106
|
+
"$ref": "members.json#/definitions/extend"
|
107
|
+
},
|
108
|
+
{
|
109
|
+
"$ref": "members.json#/definitions/prepend"
|
110
|
+
},
|
111
|
+
{
|
112
|
+
"$ref": "members.json#/definitions/attribute"
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"$ref": "members.json#/definitions/visibility"
|
116
|
+
},
|
117
|
+
{
|
118
|
+
"$ref": "members.json#/definitions/alias"
|
119
|
+
},
|
120
|
+
{
|
121
|
+
"$ref": "#/definitions/alias"
|
122
|
+
},
|
123
|
+
{
|
124
|
+
"$ref": "#/definitions/constant"
|
125
|
+
},
|
126
|
+
{
|
127
|
+
"$ref": "#/definitions/class"
|
128
|
+
},
|
129
|
+
{
|
130
|
+
"$ref": "#/definitions/module"
|
131
|
+
},
|
132
|
+
{
|
133
|
+
"$ref": "#/definitions/interface"
|
134
|
+
}
|
135
|
+
]
|
136
|
+
},
|
137
|
+
"class": {
|
138
|
+
"title": "Class declaration",
|
139
|
+
"type": "object",
|
140
|
+
"properties": {
|
141
|
+
"declaration": {
|
142
|
+
"enum": ["class"]
|
143
|
+
},
|
144
|
+
"name": {
|
145
|
+
"type": "string"
|
146
|
+
},
|
147
|
+
"type_params": {
|
148
|
+
"type": "object",
|
149
|
+
"properties": {
|
150
|
+
"params": {
|
151
|
+
"type": "array",
|
152
|
+
"items": {
|
153
|
+
"$ref": "#/definitions/moduleTypeParam"
|
154
|
+
}
|
155
|
+
}
|
156
|
+
},
|
157
|
+
"required": ["params"]
|
158
|
+
},
|
159
|
+
"members": {
|
160
|
+
"type": "array",
|
161
|
+
"items": {
|
162
|
+
"$ref": "#/definitions/classMember"
|
163
|
+
}
|
164
|
+
},
|
165
|
+
"super_class": {
|
166
|
+
"oneOf": [
|
167
|
+
{
|
168
|
+
"type": "null"
|
169
|
+
},
|
170
|
+
{
|
171
|
+
"type": "object",
|
172
|
+
"properties": {
|
173
|
+
"name": {
|
174
|
+
"type": "string"
|
175
|
+
},
|
176
|
+
"args": {
|
177
|
+
"type": "array",
|
178
|
+
"items": {
|
179
|
+
"$ref": "types.json"
|
180
|
+
}
|
181
|
+
}
|
182
|
+
},
|
183
|
+
"required": ["name", "args"]
|
184
|
+
}
|
185
|
+
]
|
186
|
+
},
|
187
|
+
"annotations": {
|
188
|
+
"type": "array",
|
189
|
+
"items": {
|
190
|
+
"$ref": "annotation.json"
|
191
|
+
}
|
192
|
+
},
|
193
|
+
"comment": {
|
194
|
+
"$ref": "comment.json"
|
195
|
+
},
|
196
|
+
"location": {
|
197
|
+
"$ref": "location.json"
|
198
|
+
}
|
199
|
+
},
|
200
|
+
"required": ["declaration", "name", "type_params", "members", "super_class", "annotations", "comment", "location"]
|
201
|
+
},
|
202
|
+
"module": {
|
203
|
+
"type": "object",
|
204
|
+
"properties": {
|
205
|
+
"declaration": {
|
206
|
+
"enum": ["module"]
|
207
|
+
},
|
208
|
+
"name": {
|
209
|
+
"type": "string"
|
210
|
+
},
|
211
|
+
"type_params": {
|
212
|
+
"type": "object",
|
213
|
+
"properties": {
|
214
|
+
"params": {
|
215
|
+
"type": "array",
|
216
|
+
"items": {
|
217
|
+
"$ref": "#/definitions/moduleTypeParam"
|
218
|
+
}
|
219
|
+
}
|
220
|
+
},
|
221
|
+
"required": ["params"]
|
222
|
+
},
|
223
|
+
"members": {
|
224
|
+
"type": "array",
|
225
|
+
"items": {
|
226
|
+
"$ref": "#/definitions/classMember"
|
227
|
+
}
|
228
|
+
},
|
229
|
+
"self_types": {
|
230
|
+
"type": "array",
|
231
|
+
"items": {
|
232
|
+
"$ref": "#/definitions/moduleSelf"
|
233
|
+
}
|
234
|
+
},
|
235
|
+
"annotations": {
|
236
|
+
"type": "array",
|
237
|
+
"items": {
|
238
|
+
"$ref": "annotation.json"
|
239
|
+
}
|
240
|
+
},
|
241
|
+
"comment": {
|
242
|
+
"$ref": "comment.json"
|
243
|
+
},
|
244
|
+
"location": {
|
245
|
+
"$ref": "location.json"
|
246
|
+
}
|
247
|
+
},
|
248
|
+
"required": ["declaration", "name", "type_params", "members", "self_types", "annotations", "location", "comment"]
|
249
|
+
},
|
250
|
+
"moduleSelf": {
|
251
|
+
"type": "object",
|
252
|
+
"properties": {
|
253
|
+
"name": {
|
254
|
+
"type": "string"
|
255
|
+
},
|
256
|
+
"args": {
|
257
|
+
"type": "array",
|
258
|
+
"items": {
|
259
|
+
"$ref": "types.json"
|
260
|
+
}
|
261
|
+
}
|
262
|
+
},
|
263
|
+
"required": ["name", "args"]
|
264
|
+
},
|
265
|
+
"interfaceMember": {
|
266
|
+
"oneOf": [
|
267
|
+
{
|
268
|
+
"allOf": [
|
269
|
+
{
|
270
|
+
"$ref": "members.json#/definitions/methodDefinition"
|
271
|
+
},
|
272
|
+
{
|
273
|
+
"type": "object",
|
274
|
+
"properties": {
|
275
|
+
"kind": {
|
276
|
+
"enum": ["instance"]
|
277
|
+
}
|
278
|
+
}
|
279
|
+
}
|
280
|
+
]
|
281
|
+
},
|
282
|
+
{
|
283
|
+
"$ref": "members.json#/definitions/include"
|
284
|
+
},
|
285
|
+
{
|
286
|
+
"$ref": "members.json#/definitions/alias"
|
287
|
+
}
|
288
|
+
]
|
289
|
+
},
|
290
|
+
"interface": {
|
291
|
+
"type": "object",
|
292
|
+
"properties": {
|
293
|
+
"declaration": {
|
294
|
+
"enum": ["interface"]
|
295
|
+
},
|
296
|
+
"name": {
|
297
|
+
"type": "string"
|
298
|
+
},
|
299
|
+
"type_params": {
|
300
|
+
"type": "object",
|
301
|
+
"properties": {
|
302
|
+
"params": {
|
303
|
+
"type": "array",
|
304
|
+
"items": {
|
305
|
+
"$ref": "#/definitions/moduleTypeParam"
|
306
|
+
}
|
307
|
+
}
|
308
|
+
},
|
309
|
+
"required": ["params"]
|
310
|
+
},
|
311
|
+
"members": {
|
312
|
+
"type": "array",
|
313
|
+
"items": {
|
314
|
+
"$ref": "#/definitions/interfaceMember"
|
315
|
+
}
|
316
|
+
},
|
317
|
+
"annotations": {
|
318
|
+
"type": "array",
|
319
|
+
"items": {
|
320
|
+
"$ref": "annotation.json"
|
321
|
+
}
|
322
|
+
},
|
323
|
+
"comment": {
|
324
|
+
"$ref": "comment.json"
|
325
|
+
},
|
326
|
+
"location": {
|
327
|
+
"$ref": "location.json"
|
328
|
+
}
|
329
|
+
},
|
330
|
+
"required": ["declaration", "name", "type_params", "members", "annotations", "comment", "location"]
|
331
|
+
}
|
332
|
+
},
|
333
|
+
"oneOf": [
|
334
|
+
{
|
335
|
+
"$ref": "#/definitions/alias"
|
336
|
+
},
|
337
|
+
{
|
338
|
+
"$ref": "#/definitions/constant"
|
339
|
+
},
|
340
|
+
{
|
341
|
+
"$ref": "#/definitions/global"
|
342
|
+
},
|
343
|
+
{
|
344
|
+
"$ref": "#/definitions/class"
|
345
|
+
},
|
346
|
+
{
|
347
|
+
"$ref": "#/definitions/module"
|
348
|
+
},
|
349
|
+
{
|
350
|
+
"$ref": "#/definitions/interface"
|
351
|
+
}
|
352
|
+
]
|
353
|
+
}
|
@@ -0,0 +1,87 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
3
|
+
"definitions": {
|
4
|
+
"param": {
|
5
|
+
"title": "Function parameter with type and optional name: `Integer size`, `::String name`, `untyped`, ...",
|
6
|
+
"type": "object",
|
7
|
+
"properties": {
|
8
|
+
"type": {
|
9
|
+
"$ref": "types.json"
|
10
|
+
},
|
11
|
+
"name": {
|
12
|
+
"oneOf": [
|
13
|
+
{
|
14
|
+
"type": "string"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"type": "null"
|
18
|
+
}
|
19
|
+
]
|
20
|
+
}
|
21
|
+
},
|
22
|
+
"required": ["type", "name"]
|
23
|
+
}
|
24
|
+
},
|
25
|
+
"properties": {
|
26
|
+
"required_positionals": {
|
27
|
+
"title": "Required positional parameters",
|
28
|
+
"type": "array",
|
29
|
+
"items": {
|
30
|
+
"$ref": "#/definitions/param"
|
31
|
+
}
|
32
|
+
},
|
33
|
+
"optional_positionals": {
|
34
|
+
"title": "Optional positional parameters",
|
35
|
+
"type": "array",
|
36
|
+
"items": {
|
37
|
+
"$ref": "#/definitions/param"
|
38
|
+
}
|
39
|
+
},
|
40
|
+
"rest_positionals": {
|
41
|
+
"title": "Rest parameter",
|
42
|
+
"oneOf": [
|
43
|
+
{
|
44
|
+
"$ref": "#/definitions/param"
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"type": "null"
|
48
|
+
}
|
49
|
+
]
|
50
|
+
},
|
51
|
+
"trailing_positionals": {
|
52
|
+
"title": "Trailing potisional parameters",
|
53
|
+
"type": "array",
|
54
|
+
"items": {
|
55
|
+
"$ref": "#/definitions/param"
|
56
|
+
}
|
57
|
+
},
|
58
|
+
"required_keywords": {
|
59
|
+
"title": "Required keyword parameters",
|
60
|
+
"additionalProperties": {
|
61
|
+
"$ref": "#/definitions/param"
|
62
|
+
}
|
63
|
+
},
|
64
|
+
"optional_keywords": {
|
65
|
+
"title": "Optional keyword parameters",
|
66
|
+
"additionalProperties": {
|
67
|
+
"$ref": "#/definitions/param"
|
68
|
+
}
|
69
|
+
},
|
70
|
+
"rest_keywords": {
|
71
|
+
"title": "Rest keyword parameters",
|
72
|
+
"oneOf": [
|
73
|
+
{
|
74
|
+
"$ref": "#/definitions/param"
|
75
|
+
},
|
76
|
+
{
|
77
|
+
"type": "null"
|
78
|
+
}
|
79
|
+
]
|
80
|
+
},
|
81
|
+
"return_type": {
|
82
|
+
"title": "Return type of a function",
|
83
|
+
"$ref": "types.json"
|
84
|
+
}
|
85
|
+
},
|
86
|
+
"required": ["required_positionals", "optional_positionals", "rest_positionals", "trailing_positionals", "required_keywords", "optional_keywords", "rest_keywords", "return_type"]
|
87
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
3
|
+
"definitions": {
|
4
|
+
"point": {
|
5
|
+
"type": "object",
|
6
|
+
"properties": {
|
7
|
+
"line": {
|
8
|
+
"type": "integer"
|
9
|
+
},
|
10
|
+
"column": {
|
11
|
+
"type": "integer"
|
12
|
+
}
|
13
|
+
},
|
14
|
+
"required": ["line", "column"]
|
15
|
+
},
|
16
|
+
"buffer": {
|
17
|
+
"type": "object",
|
18
|
+
"properties": {
|
19
|
+
"name": {
|
20
|
+
"oneOf": [
|
21
|
+
{
|
22
|
+
"type": "string"
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"type": "null"
|
26
|
+
}
|
27
|
+
]
|
28
|
+
}
|
29
|
+
},
|
30
|
+
"required": ["name"]
|
31
|
+
},
|
32
|
+
"location": {
|
33
|
+
"type": "object",
|
34
|
+
"properties": {
|
35
|
+
"start": {
|
36
|
+
"$ref": "#/definitions/point"
|
37
|
+
},
|
38
|
+
"end": {
|
39
|
+
"$ref": "#/definitions/point"
|
40
|
+
},
|
41
|
+
"buffer": {
|
42
|
+
"$ref": "#/definitions/buffer"
|
43
|
+
}
|
44
|
+
},
|
45
|
+
"required": ["start", "end", "buffer"]
|
46
|
+
}
|
47
|
+
},
|
48
|
+
"oneOf": [
|
49
|
+
{
|
50
|
+
"$ref": "#/definitions/location"
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"type": "null"
|
54
|
+
}
|
55
|
+
]
|
56
|
+
}
|