rbs 3.5.2 → 3.6.0.dev.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/dependabot.yml +5 -1
- data/.github/workflows/ruby.yml +2 -18
- data/.github/workflows/windows.yml +26 -0
- data/CHANGELOG.md +0 -12
- data/core/array.rbs +10 -10
- data/core/basic_object.rbs +3 -3
- data/core/enumerable.rbs +6 -0
- data/core/enumerator.rbs +7 -0
- data/core/fiber.rbs +1 -1
- data/core/global_variables.rbs +2 -2
- data/core/kernel.rbs +67 -38
- data/core/method.rbs +98 -7
- data/core/module.rbs +2 -2
- data/core/proc.rbs +184 -23
- data/core/ractor.rbs +1 -1
- data/core/range.rbs +30 -0
- data/core/refinement.rbs +16 -26
- data/core/symbol.rbs +34 -26
- data/core/thread.rbs +2 -2
- data/core/trace_point.rbs +12 -12
- data/core/unbound_method.rbs +1 -1
- data/docs/syntax.md +21 -9
- data/ext/rbs_extension/parser.c +135 -55
- data/ext/rbs_extension/parserstate.c +2 -7
- data/ext/rbs_extension/parserstate.h +6 -5
- data/ext/rbs_extension/ruby_objs.c +2 -1
- data/ext/rbs_extension/ruby_objs.h +1 -1
- data/lib/rbs/ast/declarations.rb +36 -0
- data/lib/rbs/ast/type_param.rb +71 -15
- data/lib/rbs/ast/visitor.rb +137 -0
- data/lib/rbs/cli/validate.rb +41 -7
- data/lib/rbs/cli.rb +3 -3
- data/lib/rbs/definition.rb +2 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +30 -4
- data/lib/rbs/definition_builder.rb +21 -6
- data/lib/rbs/environment_loader.rb +1 -1
- data/lib/rbs/errors.rb +7 -2
- data/lib/rbs/file_finder.rb +9 -12
- data/lib/rbs/locator.rb +8 -5
- data/lib/rbs/prototype/rbi.rb +2 -1
- data/lib/rbs/prototype/runtime.rb +3 -2
- data/lib/rbs/sorter.rb +9 -6
- data/lib/rbs/test/type_check.rb +6 -0
- data/lib/rbs/types.rb +11 -0
- data/lib/rbs/validator.rb +2 -2
- data/lib/rbs/vendorer.rb +3 -3
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +1 -0
- data/sig/declarations.rbs +6 -0
- data/sig/definition.rbs +1 -1
- data/sig/definition_builder.rbs +3 -1
- data/sig/errors.rbs +3 -2
- data/sig/file_finder.rbs +24 -2
- data/sig/method_types.rbs +1 -1
- data/sig/sorter.rbs +1 -1
- data/sig/type_param.rbs +41 -9
- data/sig/types.rbs +12 -0
- data/sig/visitor.rbs +47 -0
- data/stdlib/csv/0/csv.rbs +27 -0
- data/stdlib/net-http/0/net-http.rbs +1 -1
- data/stdlib/zlib/0/gzip_reader.rbs +5 -1
- metadata +6 -3
data/core/thread.rbs
CHANGED
@@ -382,7 +382,7 @@ class Thread < Object
|
|
382
382
|
# If you're going to subclass Thread, be sure to call super in your `initialize`
|
383
383
|
# method, otherwise a ThreadError will be raised.
|
384
384
|
#
|
385
|
-
def initialize: (*untyped) { (
|
385
|
+
def initialize: (*untyped) { (?) -> void } -> void
|
386
386
|
|
387
387
|
# <!--
|
388
388
|
# rdoc-file=thread.c
|
@@ -1178,7 +1178,7 @@ class Thread < Object
|
|
1178
1178
|
# calling `start` in that subclass will not invoke the subclass's `initialize`
|
1179
1179
|
# method.
|
1180
1180
|
#
|
1181
|
-
def self.start: (*untyped args) { (
|
1181
|
+
def self.start: (*untyped args) { (?) -> void } -> instance
|
1182
1182
|
|
1183
1183
|
# <!--
|
1184
1184
|
# rdoc-file=thread.c
|
data/core/trace_point.rbs
CHANGED
@@ -63,7 +63,7 @@
|
|
63
63
|
# `:script_compiled`
|
64
64
|
# : new Ruby code compiled (with `eval`, `load` or `require`)
|
65
65
|
#
|
66
|
-
class TracePoint
|
66
|
+
class TracePoint
|
67
67
|
# <!--
|
68
68
|
# rdoc-file=trace_point.rb
|
69
69
|
# - TracePoint.new(*events) { |obj| block } -> obj
|
@@ -110,7 +110,7 @@ class TracePoint < Object
|
|
110
110
|
#
|
111
111
|
# Access from other threads is also forbidden.
|
112
112
|
#
|
113
|
-
def
|
113
|
+
def self.new: (*_ToSym events) { (instance tp) -> void } -> instance
|
114
114
|
|
115
115
|
# <!--
|
116
116
|
# rdoc-file=trace_point.rb
|
@@ -172,7 +172,7 @@ class TracePoint < Object
|
|
172
172
|
# (note that we needed to filter out calls by itself from :line handler,
|
173
173
|
# otherwise it will call itself infinitely).
|
174
174
|
#
|
175
|
-
def self.allow_reentry: () { () ->
|
175
|
+
def self.allow_reentry: [T] () { (nil) -> T } -> T
|
176
176
|
|
177
177
|
# <!--
|
178
178
|
# rdoc-file=trace_point.rb
|
@@ -199,7 +199,7 @@ class TracePoint < Object
|
|
199
199
|
#
|
200
200
|
# trace.enabled? #=> true
|
201
201
|
#
|
202
|
-
def self.trace: (*
|
202
|
+
def self.trace: (*_ToSym events) { (instance tp) -> void } -> instance
|
203
203
|
|
204
204
|
# <!--
|
205
205
|
# rdoc-file=trace_point.rb
|
@@ -218,7 +218,7 @@ class TracePoint < Object
|
|
218
218
|
# -->
|
219
219
|
# Return the called name of the method being called
|
220
220
|
#
|
221
|
-
def callee_id: () -> Symbol
|
221
|
+
def callee_id: () -> Symbol?
|
222
222
|
|
223
223
|
# <!--
|
224
224
|
# rdoc-file=trace_point.rb
|
@@ -257,7 +257,7 @@ class TracePoint < Object
|
|
257
257
|
# C.foo
|
258
258
|
# end
|
259
259
|
#
|
260
|
-
def defined_class: () -> Module
|
260
|
+
def defined_class: () -> (Class | Module)?
|
261
261
|
|
262
262
|
# <!--
|
263
263
|
# rdoc-file=trace_point.rb
|
@@ -293,7 +293,7 @@ class TracePoint < Object
|
|
293
293
|
# #=> RuntimeError: access from outside
|
294
294
|
#
|
295
295
|
def disable: () -> bool
|
296
|
-
| () { () ->
|
296
|
+
| [T] () { () -> T } -> T
|
297
297
|
|
298
298
|
# <!--
|
299
299
|
# rdoc-file=trace_point.rb
|
@@ -352,8 +352,8 @@ class TracePoint < Object
|
|
352
352
|
# trace.enable { p tp.lineno }
|
353
353
|
# #=> RuntimeError: access from outside
|
354
354
|
#
|
355
|
-
def enable:
|
356
|
-
| [
|
355
|
+
def enable: (?target: Method | RubyVM::InstructionSequence | Proc | nil, ?target_line: int?, ?target_thread: Thread | :default | nil) -> bool
|
356
|
+
| [T] (?target: Method | RubyVM::InstructionSequence | Proc | nil, ?target_line: int?, ?target_thread: Thread | :default | nil) { () -> T } -> T
|
357
357
|
|
358
358
|
# <!--
|
359
359
|
# rdoc-file=trace_point.rb
|
@@ -395,7 +395,7 @@ class TracePoint < Object
|
|
395
395
|
# -->
|
396
396
|
# Return the name at the definition of the method being called
|
397
397
|
#
|
398
|
-
def method_id: () -> Symbol
|
398
|
+
def method_id: () -> Symbol?
|
399
399
|
|
400
400
|
# <!--
|
401
401
|
# rdoc-file=trace_point.rb
|
@@ -412,7 +412,7 @@ class TracePoint < Object
|
|
412
412
|
# Return the parameters definition of the method or block that the current hook
|
413
413
|
# belongs to. Format is the same as for Method#parameters
|
414
414
|
#
|
415
|
-
def parameters: () -> ::
|
415
|
+
def parameters: () -> Method::param_types?
|
416
416
|
|
417
417
|
# <!--
|
418
418
|
# rdoc-file=trace_point.rb
|
@@ -421,7 +421,7 @@ class TracePoint < Object
|
|
421
421
|
# Value from exception raised on the `:raise` event, or rescued on the `:rescue`
|
422
422
|
# event.
|
423
423
|
#
|
424
|
-
def raised_exception: () ->
|
424
|
+
def raised_exception: () -> Exception
|
425
425
|
|
426
426
|
# <!--
|
427
427
|
# rdoc-file=trace_point.rb
|
data/core/unbound_method.rbs
CHANGED
@@ -325,5 +325,5 @@ class UnboundMethod
|
|
325
325
|
# arguments. This is semantically equivalent to `umeth.bind(recv).call(args,
|
326
326
|
# ...)`.
|
327
327
|
#
|
328
|
-
def bind_call: (untyped recv, *untyped, **untyped) ?{ (
|
328
|
+
def bind_call: (untyped recv, *untyped, **untyped) ?{ (?) -> untyped } -> untyped
|
329
329
|
end
|
data/docs/syntax.md
CHANGED
@@ -64,7 +64,7 @@ Interface type denotes _type of a value which can be a subtype of the interface_
|
|
64
64
|
|
65
65
|
```rbs
|
66
66
|
_ToS # _ToS interface
|
67
|
-
::
|
67
|
+
::Enumerator::_Each[String] # Interface name with namespace and type application
|
68
68
|
```
|
69
69
|
|
70
70
|
### Alias type
|
@@ -750,16 +750,15 @@ $LOAD_PATH: Array[String]
|
|
750
750
|
### Generics
|
751
751
|
|
752
752
|
```markdown
|
753
|
-
_module-type-parameter_ ::= _generics-unchecked_ _generics-variance_ _type-variable_ _generics-bound_
|
753
|
+
_module-type-parameter_ ::= _generics-unchecked_ _generics-variance_ _type-variable_ _generics-bound_ _default-type_
|
754
754
|
|
755
755
|
_method-type-param_ ::= _type-variable_ _generics-bound_
|
756
756
|
|
757
|
-
_generics-bound_ ::=
|
758
|
-
| `<`
|
757
|
+
_generics-bound_ ::= (No type bound)
|
758
|
+
| `<` _type_ (The generics parameter is bounded)
|
759
759
|
|
760
|
-
|
761
|
-
|
762
|
-
| `singleton(` _class-name_ `)` (Class singleton type)
|
760
|
+
_default-type_ ::= (No default type)
|
761
|
+
| `=` _type_ (The generics parameter has default type)
|
763
762
|
|
764
763
|
_generics-variance_ ::= (Invariant)
|
765
764
|
| `out` (Covariant)
|
@@ -826,14 +825,27 @@ class PrettyPrint[T < _Output]
|
|
826
825
|
end
|
827
826
|
```
|
828
827
|
|
829
|
-
If a type parameter has an upper bound, the type parameter must be instantiated with types that is a
|
828
|
+
If a type parameter has an upper bound, the type parameter must be instantiated with types that is a subtype of the upper bound.
|
830
829
|
|
831
830
|
```rbs
|
832
831
|
type str_printer = PrettyPrint[String] # OK
|
833
832
|
type int_printer = PrettyPrint[Integer] # Type error
|
834
833
|
```
|
835
834
|
|
836
|
-
The
|
835
|
+
The generics type parameter of modules, classes, interfaces, or type aliases can have a default type.
|
836
|
+
|
837
|
+
```rbs
|
838
|
+
interface _Foo[T = untyped]
|
839
|
+
end
|
840
|
+
|
841
|
+
interface _Bar[T, S = untyped]
|
842
|
+
end
|
843
|
+
|
844
|
+
type foo = _Foo # equivalent to _Foo[untyped]
|
845
|
+
type bar = _Bar[String] # equivalent to _Bar[String, untyped]
|
846
|
+
```
|
847
|
+
|
848
|
+
Type parameters with default types cannot appear before type parameters without default types. The generic method type parameters cannot have the default types.
|
837
849
|
|
838
850
|
### Directives
|
839
851
|
|