rbs 1.0.5 → 1.2.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/ruby.yml +2 -2
- data/CHANGELOG.md +92 -0
- data/Rakefile +5 -2
- data/Steepfile +2 -0
- data/core/array.rbs +9 -5
- data/core/enumerable.rbs +1 -1
- data/core/enumerator.rbs +4 -0
- data/core/hash.rbs +13 -5
- data/core/io.rbs +3 -3
- data/core/module.rbs +1 -1
- data/core/numeric.rbs +10 -0
- data/core/proc.rbs +1 -1
- data/core/random.rbs +4 -2
- data/core/range.rbs +2 -2
- data/core/struct.rbs +3 -2
- data/core/thread.rbs +15 -2
- data/docs/CONTRIBUTING.md +5 -3
- data/docs/sigs.md +21 -2
- data/docs/stdlib.md +1 -1
- data/docs/syntax.md +11 -11
- data/lib/rbs.rb +4 -0
- data/lib/rbs/ancestor_graph.rb +90 -0
- data/lib/rbs/ast/annotation.rb +2 -2
- data/lib/rbs/ast/comment.rb +2 -2
- data/lib/rbs/ast/declarations.rb +37 -22
- data/lib/rbs/ast/members.rb +26 -26
- data/lib/rbs/char_scanner.rb +20 -0
- data/lib/rbs/cli.rb +3 -0
- data/lib/rbs/constant_table.rb +4 -1
- data/lib/rbs/definition.rb +1 -1
- data/lib/rbs/definition_builder.rb +52 -20
- data/lib/rbs/definition_builder/ancestor_builder.rb +1 -0
- data/lib/rbs/definition_builder/method_builder.rb +18 -2
- data/lib/rbs/environment.rb +42 -5
- data/lib/rbs/environment_walker.rb +4 -4
- data/lib/rbs/errors.rb +32 -17
- data/lib/rbs/location.rb +106 -2
- data/lib/rbs/locator.rb +205 -0
- data/lib/rbs/method_type.rb +2 -2
- data/lib/rbs/parser.rb +1153 -796
- data/lib/rbs/parser.y +431 -87
- data/lib/rbs/test/hook.rb +8 -2
- data/lib/rbs/test/type_check.rb +7 -3
- data/lib/rbs/type_name.rb +2 -3
- data/lib/rbs/type_name_resolver.rb +1 -1
- data/lib/rbs/types.rb +36 -34
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +4 -2
- data/rbs.gemspec +1 -1
- data/sig/ancestor_graph.rbs +40 -0
- data/sig/annotation.rbs +1 -1
- data/sig/char_scanner.rbs +9 -0
- data/sig/cli.rbs +31 -21
- data/sig/comment.rbs +1 -1
- data/sig/declarations.rbs +106 -21
- data/sig/definition_builder.rbs +5 -1
- data/sig/environment.rbs +24 -4
- data/sig/environment_walker.rbs +39 -0
- data/sig/errors.rbs +42 -17
- data/sig/location.rbs +84 -3
- data/sig/locator.rbs +44 -0
- data/sig/members.rbs +76 -12
- data/sig/method_builder.rbs +3 -1
- data/sig/method_types.rbs +1 -1
- data/sig/parser.rbs +11 -4
- data/sig/polyfill.rbs +13 -22
- data/sig/rbs.rbs +8 -4
- data/sig/typename.rbs +1 -1
- data/sig/types.rbs +67 -20
- data/sig/util.rbs +0 -4
- data/sig/writer.rbs +8 -2
- data/stdlib/cgi/0/core.rbs +595 -0
- data/stdlib/json/0/json.rbs +224 -0
- data/stdlib/rubygems/0/basic_specification.rbs +3 -0
- data/stdlib/rubygems/0/config_file.rbs +3 -0
- data/stdlib/rubygems/0/dependency_installer.rbs +5 -0
- data/stdlib/rubygems/0/installer.rbs +3 -0
- data/stdlib/rubygems/0/path_support.rbs +3 -0
- data/stdlib/rubygems/0/platform.rbs +3 -0
- data/stdlib/rubygems/0/request_set.rbs +7 -0
- data/stdlib/rubygems/0/requirement.rbs +85 -0
- data/stdlib/rubygems/0/rubygems.rbs +710 -0
- data/stdlib/rubygems/0/source_list.rbs +2 -0
- data/stdlib/rubygems/0/specification.rbs +3 -0
- data/stdlib/rubygems/0/stream_ui.rbs +3 -0
- data/stdlib/rubygems/0/uninstaller.rbs +3 -0
- data/stdlib/rubygems/0/version.rbs +229 -0
- data/stdlib/shellwords/0/shellwords.rbs +252 -0
- data/stdlib/strscan/0/string_scanner.rbs +582 -0
- data/steep/Gemfile.lock +19 -16
- metadata +27 -12
- data/bin/annotate-with-rdoc +0 -153
- data/bin/console +0 -14
- data/bin/query-rdoc +0 -103
- data/bin/rbs-prof +0 -9
- data/bin/run_in_md.rb +0 -49
- data/bin/setup +0 -8
- data/bin/sort +0 -89
- data/bin/steep +0 -4
- data/bin/test_runner.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99ab9c0212ca34de0fa1b8394b02713e5bc63e0904d7f95d0e1c0480635e3e39
|
4
|
+
data.tar.gz: 71be3592a61873855149305edc2b0ef3aabc97259e0ed46c697598fefddb4177
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 608db9f87d437542fe683b336198f588c670d0632ce2733570156b253d9fd4514d4b8fefacb38db0d26ed9fac149b2bfc459ff9779334bff8fa08ec103722fde
|
7
|
+
data.tar.gz: 157550825a76be4dd00a8419c001404ef0ad86406340131893a3ac7be473e7cf397da8434b4a841b6dc7f9968eceb93fdbd5f729b23c52c785725be0c1516c77
|
data/.github/workflows/ruby.yml
CHANGED
@@ -27,10 +27,10 @@ jobs:
|
|
27
27
|
run: |
|
28
28
|
apt-get update
|
29
29
|
apt-get install -y libdb-dev
|
30
|
-
- name:
|
30
|
+
- name: Update rubygems & bundler
|
31
31
|
run: |
|
32
32
|
ruby -v
|
33
|
-
gem
|
33
|
+
gem update --system
|
34
34
|
- name: bundle config set with
|
35
35
|
run: |
|
36
36
|
echo "NO_MINITEST=true" >> $GITHUB_ENV
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,98 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 1.2.1 (2021-05-27)
|
6
|
+
|
7
|
+
This release includes the following minor changes:
|
8
|
+
|
9
|
+
* Fix test to run the tests in ruby repository. ([#679](https://github.com/ruby/rbs/pull/679))
|
10
|
+
* Remove unnecessary files from the gem package. ([#675](https://github.com/ruby/rbs/pull/675))
|
11
|
+
* Suppress unused variable warning ([#674](https://github.com/ruby/rbs/pull/674))
|
12
|
+
* Update documents ([#672](https://github.com/ruby/rbs/pull/672))
|
13
|
+
|
14
|
+
## 1.2.0 (2021-04-21)
|
15
|
+
|
16
|
+
### Summary
|
17
|
+
|
18
|
+
RBS 1.2 ships with better support for AST/token locations and `Locator` utility class. The AST objects now keep the locations of tokens. The `Locator` class is to translate the text position (line and column) to semantic object at the location. The class allows to find if a text position is on the class name of a class declaration.
|
19
|
+
|
20
|
+
### Signature updates
|
21
|
+
|
22
|
+
* Hash ([#631](https://github.com/ruby/rbs/pull/631), [#632](https://github.com/ruby/rbs/pull/632), [\#637](https://github.com/ruby/rbs/pull/637), [\#638](https://github.com/ruby/rbs/pull/638), [\#639](https://github.com/ruby/rbs/pull/639), )
|
23
|
+
* Module ([\#645](https://github.com/ruby/rbs/pull/645))
|
24
|
+
* Enumerable ([\#647](https://github.com/ruby/rbs/pull/647))
|
25
|
+
* Array ([\#648](https://github.com/ruby/rbs/pull/648))
|
26
|
+
* Proc ([\#649](https://github.com/ruby/rbs/pull/649))
|
27
|
+
* Struct ([\#650](https://github.com/ruby/rbs/pull/650), [\#668](https://github.com/ruby/rbs/pull/668))
|
28
|
+
* Thread ([\#651](https://github.com/ruby/rbs/pull/651))
|
29
|
+
* Random ([\#669](https://github.com/ruby/rbs/pull/669))
|
30
|
+
* Shellwords ([\#665](https://github.com/ruby/rbs/pull/665))
|
31
|
+
* IO ([\#659](https://github.com/ruby/rbs/pull/659))
|
32
|
+
|
33
|
+
### Language updates
|
34
|
+
|
35
|
+
* Module self type syntax update ([\#653](https://github.com/ruby/rbs/pull/653))
|
36
|
+
|
37
|
+
### Library changes
|
38
|
+
|
39
|
+
* Token locations ([\#666](https://github.com/ruby/rbs/pull/666))
|
40
|
+
* Add RBS::Locator ([\#667](https://github.com/ruby/rbs/pull/667))
|
41
|
+
* Fix runtime type checker ([\#644](https://github.com/ruby/rbs/pull/644))
|
42
|
+
|
43
|
+
### Miscellaneous
|
44
|
+
|
45
|
+
* Update documentation for overloading ([\#658](https://github.com/ruby/rbs/pull/658))
|
46
|
+
* Update target ruby version ([\#633](https://github.com/ruby/rbs/pull/633))
|
47
|
+
|
48
|
+
## 1.1.1 (2021-03-12)
|
49
|
+
|
50
|
+
### Signature updates
|
51
|
+
|
52
|
+
* rubygem ([#630](https://github.com/ruby/rbs/pull/630))
|
53
|
+
|
54
|
+
## 1.1.0 (2021-03-08)
|
55
|
+
|
56
|
+
### Summary
|
57
|
+
|
58
|
+
Errors are now organized by `RBS::BaseError`, `RBS::ParsingError`, `RBS::LoadingError`, and `RBS::DefinitionError`.
|
59
|
+
The library users can rescue RBS related errors with `RBS::BaseError`, parsing errors with `RBS::ParsingError`, and other errors with `RBS::LoadingError` and `RBS::DefinitionErrors`.
|
60
|
+
|
61
|
+
Updating a part of environments are supported. Library users can remove declarations read from a set of files, adding new declarations, running name resolution related to the new decls, and deleting `DefinitionBuilder` caches related to the changes.
|
62
|
+
See `RBS::Environment#reject`, `RBS::Environment#resolve_type_names`, `RBS::AncestorGraph`, and `RBS::DefinitionBuilder#update`.
|
63
|
+
|
64
|
+
`RBS::DefinitionBuilder#build_singleton` now returns definitions containing `instance` type, which had returned resolved class instance types. This is a breaking change, but we consider it a bug fix because `RBS::DefinitionBuilder#build_instance` has returned `instance` types and `#build_singleton` has returned `class` type.
|
65
|
+
|
66
|
+
### Signature updates
|
67
|
+
|
68
|
+
* rubygem ([\#605](https://github.com/ruby/rbs/pull/605), [\#610](https://github.com/ruby/rbs/pull/610))
|
69
|
+
* Array ([\#612](https://github.com/ruby/rbs/pull/612), [\#614](https://github.com/ruby/rbs/pull/614))
|
70
|
+
* cgi/core ([\#599](https://github.com/ruby/rbs/pull/599))
|
71
|
+
* Thread ([\#618](https://github.com/ruby/rbs/pull/618))
|
72
|
+
|
73
|
+
### Language updates
|
74
|
+
|
75
|
+
* Allow trailing comma for Record and Tuple types ([\#606](https://github.com/ruby/rbs/pull/606))
|
76
|
+
|
77
|
+
### Library changes
|
78
|
+
|
79
|
+
* Allow partial update of RBS declarations ([\#608](https://github.com/ruby/rbs/pull/608), [\#621](https://github.com/ruby/rbs/pull/621))
|
80
|
+
* Let errors have `TypeName` ([\#611](https://github.com/ruby/rbs/pull/611))
|
81
|
+
* Add `Parser::LexerError` ([\#615](https://github.com/ruby/rbs/pull/615))
|
82
|
+
* Performance improvement ([\#617](https://github.com/ruby/rbs/pull/617), [\#620](https://github.com/ruby/rbs/pull/620))
|
83
|
+
* No substitute `instance` types on `#build_singleton` ([\#619](https://github.com/ruby/rbs/pull/619))
|
84
|
+
|
85
|
+
### Miscellaneous
|
86
|
+
|
87
|
+
* Make racc name customizable by `RACC` environment variable ([\#602](https://github.com/ruby/rbs/pull/602))
|
88
|
+
* Suppress warnings ([\#624](https://github.com/ruby/rbs/pull/624))
|
89
|
+
* Remove needless `Gem::Version` polyfill ([\#622](https://github.com/ruby/rbs/pull/622))
|
90
|
+
|
91
|
+
## 1.0.6 (2021-02-17)
|
92
|
+
|
93
|
+
* Signature Updates
|
94
|
+
* `Enumerable` ([\#595](https://github.com/ruby/rbs/pull/595), [\#596](https://github.com/ruby/rbs/pull/596), [\#601](https://github.com/ruby/rbs/pull/601))
|
95
|
+
* `#as_json` ([\#597](https://github.com/ruby/rbs/pull/597))
|
96
|
+
|
5
97
|
## 1.0.5 (2021-02-13)
|
6
98
|
|
7
99
|
* Signature Updates
|
data/Rakefile
CHANGED
@@ -2,7 +2,10 @@ require "bundler/gem_tasks"
|
|
2
2
|
require "rake/testtask"
|
3
3
|
require "rbconfig"
|
4
4
|
|
5
|
+
$LOAD_PATH << File.join(__dir__, "test")
|
6
|
+
|
5
7
|
ruby = ENV["RUBY"] || RbConfig.ruby
|
8
|
+
racc = ENV.fetch("RACC", "racc")
|
6
9
|
rbs = File.join(__dir__, "exe/rbs")
|
7
10
|
bin = File.join(__dir__, "bin")
|
8
11
|
|
@@ -67,7 +70,7 @@ task :rubocop do
|
|
67
70
|
end
|
68
71
|
|
69
72
|
rule ".rb" => ".y" do |t|
|
70
|
-
sh "racc -v -o #{t.name} #{t.source}"
|
73
|
+
sh "#{racc} -v -o #{t.name} #{t.source}"
|
71
74
|
end
|
72
75
|
|
73
76
|
task :parser => "lib/rbs/parser.rb"
|
@@ -77,7 +80,7 @@ task :build => :parser
|
|
77
80
|
|
78
81
|
task :confirm_parser do
|
79
82
|
puts "Testing if parser.rb is updated with respect to parser.y"
|
80
|
-
sh "racc -v -o lib/rbs/parser.rb lib/rbs/parser.y"
|
83
|
+
sh "#{racc} -v -o lib/rbs/parser.rb lib/rbs/parser.y"
|
81
84
|
sh "git diff --exit-code lib/rbs/parser.rb"
|
82
85
|
end
|
83
86
|
|
data/Steepfile
CHANGED
data/core/array.rbs
CHANGED
@@ -682,7 +682,7 @@ class Array[unchecked out Elem] < Object
|
|
682
682
|
#
|
683
683
|
# See also Array#+.
|
684
684
|
#
|
685
|
-
def concat: (*::Array[Elem] arrays) ->
|
685
|
+
def concat: (*::Array[Elem] arrays) -> self
|
686
686
|
|
687
687
|
# Returns the number of elements.
|
688
688
|
#
|
@@ -1584,8 +1584,8 @@ class Array[unchecked out Elem] < Object
|
|
1584
1584
|
# a.sample(random: Random.new(1)) #=> 6
|
1585
1585
|
# a.sample(4, random: Random.new(1)) #=> [6, 10, 9, 2]
|
1586
1586
|
#
|
1587
|
-
def sample: (?random:
|
1588
|
-
| (?int n, ?random:
|
1587
|
+
def sample: (?random: _Rand rng) -> Elem?
|
1588
|
+
| (?int n, ?random: _Rand rng) -> ::Array[Elem]
|
1589
1589
|
|
1590
1590
|
# Returns a new array containing all elements of `ary` for which the given
|
1591
1591
|
# `block` returns a true value.
|
@@ -1649,7 +1649,7 @@ class Array[unchecked out Elem] < Object
|
|
1649
1649
|
#
|
1650
1650
|
# a.shuffle(random: Random.new(1)) #=> [1, 3, 2]
|
1651
1651
|
#
|
1652
|
-
def shuffle: (?random:
|
1652
|
+
def shuffle: (?random: _Rand rng) -> ::Array[Elem]
|
1653
1653
|
|
1654
1654
|
# Shuffles elements in `self` in place.
|
1655
1655
|
#
|
@@ -1661,7 +1661,7 @@ class Array[unchecked out Elem] < Object
|
|
1661
1661
|
#
|
1662
1662
|
# a.shuffle!(random: Random.new(1)) #=> [1, 3, 2]
|
1663
1663
|
#
|
1664
|
-
def shuffle!: (?random:
|
1664
|
+
def shuffle!: (?random: _Rand rng) -> self
|
1665
1665
|
|
1666
1666
|
alias size length
|
1667
1667
|
|
@@ -1997,6 +1997,10 @@ interface _ToAry[T]
|
|
1997
1997
|
def to_ary: () -> ::Array[T]
|
1998
1998
|
end
|
1999
1999
|
|
2000
|
+
interface _Rand
|
2001
|
+
def rand: (::Integer max) -> ::Integer
|
2002
|
+
end
|
2003
|
+
|
2000
2004
|
interface Array::_Pattern[T]
|
2001
2005
|
def ===: (T) -> bool
|
2002
2006
|
end
|
data/core/enumerable.rbs
CHANGED
@@ -118,7 +118,7 @@ module Enumerable[unchecked out Elem]: _Each[Elem]
|
|
118
118
|
# [].first(10) #=> []
|
119
119
|
# ```
|
120
120
|
def first: () -> Elem?
|
121
|
-
| (
|
121
|
+
| (_ToInt n) -> ::Array[Elem]
|
122
122
|
|
123
123
|
def grep: (untyped arg0) -> ::Array[Elem]
|
124
124
|
| [U] (untyped arg0) { (Elem arg0) -> U } -> ::Array[U]
|
data/core/enumerator.rbs
CHANGED
@@ -244,6 +244,8 @@ end
|
|
244
244
|
|
245
245
|
class Enumerator::Generator[out Elem] < Object
|
246
246
|
include Enumerable[Elem]
|
247
|
+
|
248
|
+
def each: () { (Elem) -> void } -> void
|
247
249
|
end
|
248
250
|
|
249
251
|
class Enumerator::Lazy[out Elem, out Return] < Enumerator[Elem, Return]
|
@@ -259,4 +261,6 @@ end
|
|
259
261
|
|
260
262
|
class Enumerator::Chain[out Elem] < Object
|
261
263
|
include Enumerable[Elem]
|
264
|
+
|
265
|
+
def each: () { (Elem) -> void } -> void
|
262
266
|
end
|
data/core/hash.rbs
CHANGED
@@ -256,7 +256,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
256
256
|
# h.compact #=> { a: 1, b: false }
|
257
257
|
# h #=> { a: 1, b: false, c: nil }
|
258
258
|
#
|
259
|
-
def compact: () ->
|
259
|
+
def compact: () -> ::Hash[K, V]
|
260
260
|
|
261
261
|
# Removes all nil values from the hash. Returns nil if no changes were made,
|
262
262
|
# otherwise returns the hash.
|
@@ -450,6 +450,14 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
450
450
|
#
|
451
451
|
def eql?: (untyped) -> bool
|
452
452
|
|
453
|
+
# Returns a hash excluded given keys and the values.
|
454
|
+
#
|
455
|
+
# h = { a: 100, b: 200, c: 300 }
|
456
|
+
# h.except(:a) #=> {:b=>200, :c=>300}
|
457
|
+
# h.except(:b, :c, :d) #=> {:a=>100}
|
458
|
+
#
|
459
|
+
def except: (*K) -> ::Hash[K, V]
|
460
|
+
|
453
461
|
# Returns a value from the hash for the given key. If the key can't be found,
|
454
462
|
# there are several options: With no other arguments, it will raise a KeyError
|
455
463
|
# exception; if *default* is given, then that will be returned; if the optional
|
@@ -498,8 +506,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
498
506
|
#
|
499
507
|
# Hash#filter is an alias for Hash#select.
|
500
508
|
#
|
501
|
-
def filter: () { (K, V) -> boolish } ->
|
502
|
-
| () -> ::Enumerator[[ K, V ],
|
509
|
+
def filter: () { (K, V) -> boolish } -> ::Hash[K, V]
|
510
|
+
| () -> ::Enumerator[[ K, V ], ::Hash[K, V]]
|
503
511
|
|
504
512
|
# Equivalent to Hash#keep_if, but returns `nil` if no changes were made.
|
505
513
|
#
|
@@ -815,7 +823,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
815
823
|
# h.slice(:a) #=> {:a=>100}
|
816
824
|
# h.slice(:b, :c, :d) #=> {:b=>200, :c=>300}
|
817
825
|
#
|
818
|
-
def slice: (*K) ->
|
826
|
+
def slice: (*K) -> ::Hash[K, V]
|
819
827
|
|
820
828
|
# ## Element Assignment
|
821
829
|
#
|
@@ -857,7 +865,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
857
865
|
|
858
866
|
# Returns `self`.
|
859
867
|
#
|
860
|
-
def to_hash: () ->
|
868
|
+
def to_hash: () -> self
|
861
869
|
|
862
870
|
# Returns a Proc which maps keys to values.
|
863
871
|
#
|
data/core/io.rbs
CHANGED
@@ -181,7 +181,7 @@ class IO < Object
|
|
181
181
|
# # ...
|
182
182
|
# f.gets # won't cause Errno::EBADF
|
183
183
|
#
|
184
|
-
def autoclose=: (
|
184
|
+
def autoclose=: (boolish) -> untyped
|
185
185
|
|
186
186
|
# Returns `true` if the underlying file descriptor of *ios* will be closed
|
187
187
|
# automatically at its finalization, otherwise `false`.
|
@@ -212,7 +212,7 @@ class IO < Object
|
|
212
212
|
# just ignored since Ruby 2.3.
|
213
213
|
def close: () -> NilClass
|
214
214
|
|
215
|
-
def close_on_exec=: (boolish) ->
|
215
|
+
def close_on_exec=: (boolish) -> untyped
|
216
216
|
|
217
217
|
# Returns `true` if *ios* will be closed on exec.
|
218
218
|
#
|
@@ -656,7 +656,7 @@ class IO < Object
|
|
656
656
|
# ```
|
657
657
|
def sync: () -> bool
|
658
658
|
|
659
|
-
def sync=: (boolish) ->
|
659
|
+
def sync=: (boolish) -> untyped
|
660
660
|
|
661
661
|
def sysread: (Integer maxlen, String outbuf) -> String
|
662
662
|
|
data/core/module.rbs
CHANGED
@@ -158,7 +158,7 @@ class Module < Object
|
|
158
158
|
#
|
159
159
|
# Exiting with code 99
|
160
160
|
#
|
161
|
-
def alias_method: (Symbol new_name, Symbol old_name) ->
|
161
|
+
def alias_method: (::Symbol | ::String new_name, ::Symbol | ::String old_name) -> ::Symbol
|
162
162
|
|
163
163
|
# Returns a list of modules included/prepended in *mod* (including *mod*
|
164
164
|
# itself).
|
data/core/numeric.rbs
CHANGED
@@ -82,10 +82,20 @@ class Numeric
|
|
82
82
|
#
|
83
83
|
def %: (Numeric) -> Numeric
|
84
84
|
|
85
|
+
# Performs addition: the class of the resulting object depends on the class of
|
86
|
+
# `numeric`.
|
87
|
+
#
|
88
|
+
def +: (Numeric) -> Numeric
|
89
|
+
|
85
90
|
# Unary Plus---Returns the receiver.
|
86
91
|
#
|
87
92
|
def +@: () -> Numeric
|
88
93
|
|
94
|
+
# Performs subtraction: the class of the resulting object depends on the class
|
95
|
+
# of `numeric`.
|
96
|
+
#
|
97
|
+
def -: (Numeric) -> Numeric
|
98
|
+
|
89
99
|
# Unary Minus---Returns the receiver, negated.
|
90
100
|
#
|
91
101
|
def -@: () -> Numeric
|
data/core/proc.rbs
CHANGED
data/core/random.rbs
CHANGED
@@ -106,7 +106,9 @@ class Random < Object
|
|
106
106
|
|
107
107
|
# Alias of Random::DEFAULT.rand.
|
108
108
|
#
|
109
|
-
def self.rand: (
|
109
|
+
def self.rand: () -> Float
|
110
|
+
| (Integer | ::Range[Integer] max) -> Integer
|
111
|
+
| (Float | ::Range[Float] max) -> Float
|
110
112
|
|
111
113
|
# Seeds the system pseudo-random number generator, Random::DEFAULT, with
|
112
114
|
# `number`. The previous seed value is returned.
|
@@ -126,7 +128,7 @@ class Random < Object
|
|
126
128
|
# srand 1234 # => 1234
|
127
129
|
# [ rand, rand ] # => [0.1915194503788923, 0.6221087710398319]
|
128
130
|
#
|
129
|
-
def self.srand: (?Integer number) ->
|
131
|
+
def self.srand: (?Integer number) -> Integer
|
130
132
|
end
|
131
133
|
|
132
134
|
# The default Pseudorandom number generator. Used by class methods of Random.
|
data/core/range.rbs
CHANGED
@@ -99,7 +99,7 @@ class Range[out Elem] < Object
|
|
99
99
|
# ```ruby
|
100
100
|
# (1..10).begin #=> 1
|
101
101
|
# ```
|
102
|
-
def begin: () -> Elem
|
102
|
+
def begin: () -> Elem # Begin-less ranges have type of Range[Integer?]
|
103
103
|
|
104
104
|
def bsearch: [U] () { (Elem) -> boolish } -> U?
|
105
105
|
|
@@ -114,7 +114,7 @@ class Range[out Elem] < Object
|
|
114
114
|
# (1..10).end #=> 10
|
115
115
|
# (1...10).end #=> 10
|
116
116
|
# ```
|
117
|
-
def `end`: () -> Elem
|
117
|
+
def `end`: () -> Elem # End-less ranges have type of Range[Integer?]
|
118
118
|
|
119
119
|
# Returns `true` if the range excludes its end value.
|
120
120
|
#
|
data/core/struct.rbs
CHANGED
@@ -27,13 +27,14 @@
|
|
27
27
|
# struct member which is either a quoted string ( `"name"` ) or a
|
28
28
|
# [Symbol](https://ruby-doc.org/core-2.6.3/Symbol.html) ( `:name` ).
|
29
29
|
class Struct[Elem] < Object
|
30
|
-
include Enumerable[Elem]
|
30
|
+
include Enumerable[Elem?]
|
31
31
|
|
32
32
|
type attribute_name = Symbol | String
|
33
33
|
|
34
34
|
def initialize: (attribute_name, *attribute_name, ?keyword_init: boolish) ?{ () -> void } -> void
|
35
35
|
|
36
|
-
def each: ()
|
36
|
+
def each: () -> ::Enumerator[Elem?, self]
|
37
|
+
| () { (Elem? item) -> void } -> self
|
37
38
|
|
38
39
|
def self.members: () -> ::Array[Symbol]
|
39
40
|
end
|
data/core/thread.rbs
CHANGED
@@ -287,7 +287,20 @@ class Thread < Object
|
|
287
287
|
|
288
288
|
def group: () -> ThreadGroup?
|
289
289
|
|
290
|
-
|
290
|
+
# Creates a new thread executing the given block.
|
291
|
+
#
|
292
|
+
# Any `args` given to ::new will be passed to the block:
|
293
|
+
#
|
294
|
+
# arr = []
|
295
|
+
# a, b, c = 1, 2, 3
|
296
|
+
# Thread.new(a,b,c) { |d,e,f| arr << d << e << f }.join
|
297
|
+
# arr #=> [1, 2, 3]
|
298
|
+
#
|
299
|
+
# A ThreadError exception is raised if ::new is called without a block.
|
300
|
+
#
|
301
|
+
# If you're going to subclass Thread, be sure to call super in your `initialize`
|
302
|
+
# method, otherwise a ThreadError will be raised.
|
303
|
+
def initialize: (*untyped) { (*untyped) -> void } -> void
|
291
304
|
|
292
305
|
# The calling thread will suspend execution and run this `thr` .
|
293
306
|
#
|
@@ -829,7 +842,7 @@ class Thread < Object
|
|
829
842
|
# However, if class [Thread](Thread.downloaded.ruby_doc) is subclassed,
|
830
843
|
# then calling `start` in that subclass will not invoke the subclass’s
|
831
844
|
# `initialize` method.
|
832
|
-
def self.start: (*untyped args) ->
|
845
|
+
def self.start: (*untyped args) { (*untyped) -> void } -> instance
|
833
846
|
|
834
847
|
# Stops execution of the current thread, putting it into a “sleep” state,
|
835
848
|
# and schedules execution of another thread.
|