rbs 3.5.3 → 3.6.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dependabot.yml +5 -1
  3. data/.github/workflows/ruby.yml +2 -18
  4. data/.github/workflows/windows.yml +26 -0
  5. data/.rubocop.yml +28 -1
  6. data/CHANGELOG.md +58 -0
  7. data/Rakefile +8 -2
  8. data/core/array.rbs +10 -10
  9. data/core/basic_object.rbs +4 -4
  10. data/core/builtin.rbs +4 -4
  11. data/core/dir.rbs +1 -1
  12. data/core/enumerable.rbs +17 -11
  13. data/core/enumerator/product.rbs +1 -1
  14. data/core/enumerator.rbs +9 -2
  15. data/core/errors.rbs +1 -1
  16. data/core/exception.rbs +1 -1
  17. data/core/fiber.rbs +1 -1
  18. data/core/file.rbs +1 -1
  19. data/core/global_variables.rbs +2 -2
  20. data/core/integer.rbs +4 -4
  21. data/core/kernel.rbs +69 -40
  22. data/core/method.rbs +98 -7
  23. data/core/module.rbs +3 -3
  24. data/core/proc.rbs +184 -23
  25. data/core/ractor.rbs +1 -1
  26. data/core/random.rbs +1 -1
  27. data/core/range.rbs +30 -0
  28. data/core/rbs/unnamed/env_class.rbs +7 -7
  29. data/core/rbs/unnamed/random.rbs +14 -14
  30. data/core/refinement.rbs +16 -26
  31. data/core/regexp.rbs +2 -2
  32. data/core/symbol.rbs +34 -26
  33. data/core/thread.rbs +8 -7
  34. data/core/trace_point.rbs +12 -12
  35. data/core/unbound_method.rbs +1 -1
  36. data/docs/syntax.md +26 -12
  37. data/ext/rbs_extension/lexer.c +1 -1
  38. data/ext/rbs_extension/lexer.h +5 -0
  39. data/ext/rbs_extension/lexer.re +1 -1
  40. data/ext/rbs_extension/lexstate.c +16 -0
  41. data/ext/rbs_extension/location.c +27 -39
  42. data/ext/rbs_extension/location.h +7 -2
  43. data/ext/rbs_extension/parser.c +119 -51
  44. data/ext/rbs_extension/ruby_objs.c +2 -1
  45. data/ext/rbs_extension/ruby_objs.h +1 -1
  46. data/lib/rbs/ast/declarations.rb +36 -0
  47. data/lib/rbs/ast/type_param.rb +71 -15
  48. data/lib/rbs/ast/visitor.rb +137 -0
  49. data/lib/rbs/buffer.rb +5 -0
  50. data/lib/rbs/cli/validate.rb +81 -7
  51. data/lib/rbs/cli.rb +3 -3
  52. data/lib/rbs/definition.rb +2 -1
  53. data/lib/rbs/definition_builder/ancestor_builder.rb +30 -4
  54. data/lib/rbs/definition_builder.rb +21 -6
  55. data/lib/rbs/environment_loader.rb +1 -1
  56. data/lib/rbs/errors.rb +8 -3
  57. data/lib/rbs/file_finder.rb +9 -12
  58. data/lib/rbs/location_aux.rb +2 -6
  59. data/lib/rbs/locator.rb +8 -5
  60. data/lib/rbs/prototype/rbi.rb +2 -1
  61. data/lib/rbs/prototype/runtime.rb +3 -2
  62. data/lib/rbs/sorter.rb +9 -6
  63. data/lib/rbs/test/type_check.rb +13 -0
  64. data/lib/rbs/types.rb +11 -0
  65. data/lib/rbs/validator.rb +2 -2
  66. data/lib/rbs/vendorer.rb +3 -3
  67. data/lib/rbs/version.rb +1 -1
  68. data/lib/rbs.rb +1 -0
  69. data/sig/declarations.rbs +6 -0
  70. data/sig/definition.rbs +1 -1
  71. data/sig/definition_builder.rbs +3 -1
  72. data/sig/errors.rbs +3 -2
  73. data/sig/file_finder.rbs +24 -2
  74. data/sig/location.rbs +0 -3
  75. data/sig/method_types.rbs +1 -1
  76. data/sig/sorter.rbs +1 -1
  77. data/sig/type_param.rbs +41 -9
  78. data/sig/types.rbs +12 -0
  79. data/sig/visitor.rbs +47 -0
  80. data/stdlib/csv/0/csv.rbs +44 -6
  81. data/stdlib/digest/0/digest.rbs +22 -28
  82. data/stdlib/ipaddr/0/ipaddr.rbs +1 -1
  83. data/stdlib/kconv/0/kconv.rbs +166 -0
  84. data/stdlib/net-http/0/net-http.rbs +2 -2
  85. data/stdlib/psych/0/store.rbs +1 -1
  86. data/stdlib/uri/0/ldap.rbs +1 -1
  87. data/stdlib/zlib/0/deflate.rbs +1 -1
  88. data/stdlib/zlib/0/gzip_reader.rbs +5 -1
  89. metadata +6 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd64311918171dfbd09f9f589ce34a9f090f145f31d7a687ef1117551913e35d
4
- data.tar.gz: e9abb9591ee16228cea0b0f07806fc1eef6271944222ed07f4d7d849b8962611
3
+ metadata.gz: 6884f033b29e9db43f782ee20e91a89d329fa51271d015fe0d25d4f4c1dd8166
4
+ data.tar.gz: 11db8e1f37cae5204b74d126c80e7b6b75990a33dec81f00519967a517cdf17e
5
5
  SHA512:
6
- metadata.gz: 046b790474ee8c0cd8f3c1a69531ccf3b3d95df6ef9cd46cf3f89224a6ac0964776025d01c2bb2d094c211e88cb93925a03693e66a7d7986961384cc5d5e229a
7
- data.tar.gz: 1a191fe2488617141c975b3479666138e75a31f37cbdbadcae7a6032e5031e09a8e74c2699e5f928692c0a12fb8dfa9e8332edd3ac45ae46001e88652bff589f
6
+ metadata.gz: 9193fb829e1503c2179cc802c20b37bd1b8ed25417bf032a642da25689e0709a753525f5bf2424c57caf4bc57aeb9a5cf03c0062b11e2d36632b1e8b6ae77c31
7
+ data.tar.gz: 13a766ee6f81f3ad426af8e6de51289fea8d656b848d038afc15fc21eda0fabc3f525e5035df02b09948113ae0f8ada0965ede862cd17efb52a72ce42631862a
@@ -11,8 +11,11 @@ env:
11
11
  jobs:
12
12
  dependabot:
13
13
  runs-on: ubuntu-latest
14
- if: ${{ github.actor == 'dependabot[bot]' }}
14
+ if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
15
15
  steps:
16
+ - name: Dependabot metadata
17
+ uses: dependabot/fetch-metadata@dbb049abf0d677abbd7f7eee0375145b417fdd34 # v2.2.0
18
+ id: metadata
16
19
  - name: Checkout repository
17
20
  uses: actions/checkout@v4
18
21
  with:
@@ -21,6 +24,7 @@ jobs:
21
24
  run: git diff --exit-code ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} ${{ env.blocker_files }}
22
25
  - name: Enable auto-merge for Dependabot PRs
23
26
  run: gh pr merge --auto --merge "$PR_URL"
27
+ if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch' }}
24
28
  env:
25
29
  PR_URL: ${{github.event.pull_request.html_url}}
26
30
  GH_TOKEN: ${{secrets.DEPENDABOT_MERGE_GH_TOKEN}}
@@ -42,6 +42,8 @@ jobs:
42
42
  bundler: none
43
43
  - name: Set working directory as safe
44
44
  run: git config --global --add safe.directory $(pwd)
45
+ - name: Set up permission
46
+ run: chmod -R o-w /opt/hostedtoolcache/Ruby
45
47
  - name: Install dependencies
46
48
  run: |
47
49
  sudo apt-get update
@@ -76,21 +78,3 @@ jobs:
76
78
  - name: Run test
77
79
  run: |
78
80
  bundle exec rake ${{ matrix.job }}
79
-
80
- windows:
81
- runs-on: ${{ matrix.os }}
82
- strategy:
83
- fail-fast: false
84
- matrix:
85
- os: [windows-2019, windows-2022]
86
- ruby: [ucrt, mswin]
87
- steps:
88
- - uses: actions/checkout@v4
89
- - name: load ruby
90
- uses: ruby/setup-ruby@v1
91
- with:
92
- ruby-version: ${{ matrix.ruby }}
93
- - name: rake-compiler
94
- run: gem install rake-compiler
95
- - name: compile
96
- run: rake compile
@@ -0,0 +1,26 @@
1
+ name: Ruby on Windows
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request: {}
8
+ merge_group: {}
9
+
10
+ jobs:
11
+ compile:
12
+ runs-on: "windows-latest"
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ ruby: ['3.2', '3.3', ucrt, mswin]
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - name: load ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+ - name: rake-compiler
24
+ run: gem install rake-compiler
25
+ - name: compile
26
+ run: rake compile
data/.rubocop.yml CHANGED
@@ -1,4 +1,7 @@
1
- require: rubocop-rubycw
1
+ require:
2
+ - rubocop-rubycw
3
+ - rubocop-on-rbs
4
+
2
5
  AllCops:
3
6
  TargetRubyVersion: 3.0
4
7
  DisabledByDefault: true
@@ -8,6 +11,30 @@ Rubycw/Rubycw:
8
11
  Enabled: true
9
12
  Exclude:
10
13
  - 'test/**/*_test.rb'
14
+ - 'test/typecheck/**/*.rb'
15
+
16
+ RBS:
17
+ Enabled: true
18
+ RBS/Layout:
19
+ Enabled: true
20
+ Exclude:
21
+ - 'sig/**/*'
22
+ - 'test/**/*'
23
+ RBS/Layout/CommentIndentation:
24
+ Exclude:
25
+ - core/string.rbs
26
+ RBS/Lint:
27
+ Enabled: true
28
+ Exclude:
29
+ - 'sig/**/*'
30
+ - 'test/**/*'
31
+ RBS/Style:
32
+ Enabled: false
33
+ Exclude:
34
+ - 'sig/**/*'
35
+ - 'test/**/*'
36
+ RBS/Style/InitializeReturnType:
37
+ Enabled: true
11
38
 
12
39
  Lint/DuplicateMethods:
13
40
  Enabled: true
data/CHANGELOG.md CHANGED
@@ -1,5 +1,63 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 3.6.0.pre.1 (2024-09-17)
4
+
5
+ ### Signature updates
6
+
7
+ * csv ([#2012](https://github.com/ruby/rbs/pull/2012), [#1864](https://github.com/ruby/rbs/pull/1864), [#2002](https://github.com/ruby/rbs/pull/2002), [#2003](https://github.com/ruby/rbs/pull/2003), [#1903](https://github.com/ruby/rbs/pull/1903))
8
+ * digest ([#1880](https://github.com/ruby/rbs/pull/1880))
9
+ * kconv ([#1857](https://github.com/ruby/rbs/pull/1857))
10
+ * zlib ([#1911](https://github.com/ruby/rbs/pull/1911))
11
+ * `_Each` ([#2006](https://github.com/ruby/rbs/pull/2006))
12
+ * `Array` ([#1921](https://github.com/ruby/rbs/pull/1921))
13
+ * `Enumerable` ([#1921](https://github.com/ruby/rbs/pull/1921))
14
+ * `Enumerator::_Each` ([#2006](https://github.com/ruby/rbs/pull/2006), [#1915](https://github.com/ruby/rbs/pull/1915))
15
+ * `Enumerator` ([#2004](https://github.com/ruby/rbs/pull/2004))
16
+ * `Kernel` ([#1945](https://github.com/ruby/rbs/pull/1945))
17
+ * `Method` ([#1939](https://github.com/ruby/rbs/pull/1939))
18
+ * `Module` ([#1921](https://github.com/ruby/rbs/pull/1921))
19
+ * `Net::HTTPHeader` ([#1932](https://github.com/ruby/rbs/pull/1932))
20
+ * `Proc` ([#1937](https://github.com/ruby/rbs/pull/1937))
21
+ * `Queue` ([#2004](https://github.com/ruby/rbs/pull/2004))
22
+ * `Range` ([#1921](https://github.com/ruby/rbs/pull/1921))
23
+ * `Refinement` ([#1931](https://github.com/ruby/rbs/pull/1931))
24
+ * `Symbol` ([#1930](https://github.com/ruby/rbs/pull/1930))
25
+ * `TracePoint` ([#1943](https://github.com/ruby/rbs/pull/1943))
26
+ * `#rand` ([#2007](https://github.com/ruby/rbs/pull/2007))
27
+ * Use untyped blocks ([#1935](https://github.com/ruby/rbs/pull/1935))
28
+ * Update docs for ruby-3.3.4 ([#1923](https://github.com/ruby/rbs/pull/1923))
29
+ * Update docs for ruby-3.3.3 ([#1889](https://github.com/ruby/rbs/pull/1889))
30
+
31
+ ### Language updates
32
+
33
+ * Fix position for default_type ([#1997](https://github.com/ruby/rbs/pull/1997))
34
+ * Update `syntax.md` ([#1995](https://github.com/ruby/rbs/pull/1995))
35
+ * Improve generics ([#1994](https://github.com/ruby/rbs/pull/1994))
36
+ * Allow alias to module-self-type from module ([#1948](https://github.com/ruby/rbs/pull/1948))
37
+ * Make it a syntax error when the keys of keyword and record are duplicated. ([#1883](https://github.com/ruby/rbs/pull/1883))
38
+
39
+ ### Library changes
40
+
41
+ * Omit unnecessary field from location range ([#1788](https://github.com/ruby/rbs/pull/1788))
42
+ * Handle ISEQs compiled by Prism ([#1983](https://github.com/ruby/rbs/pull/1983))
43
+ * Add AST Visitor ([#1975](https://github.com/ruby/rbs/pull/1975))
44
+ * Make the extension `GC.auto_compact` compatible ([#1971](https://github.com/ruby/rbs/pull/1971))
45
+ * Make `FileFinder` faster by globbing all possible files ([#1965](https://github.com/ruby/rbs/pull/1965))
46
+ * Fix #1905: Fix typo in `UntypedFunction` ([#1906](https://github.com/ruby/rbs/pull/1906))
47
+
48
+ #### rbs prototype
49
+
50
+ * [prototype] Remove redundant access modifier ([#1914](https://github.com/ruby/rbs/pull/1914))
51
+
52
+ ### Miscellaneous
53
+
54
+ * Allow RBS/Style/InitializeReturnType ([#2008](https://github.com/ruby/rbs/pull/2008))
55
+ * docs: An interface can include interfaces only and not modules ([#1996](https://github.com/ruby/rbs/pull/1996))
56
+ * Fix the portability of an external command ([#2001](https://github.com/ruby/rbs/pull/2001))
57
+ * Skip `AbstractSyntaxTree` test with ruby-3.4 ([#2005](https://github.com/ruby/rbs/pull/2005))
58
+ * Fix test ([#1972](https://github.com/ruby/rbs/pull/1972))
59
+ * Use `File.open` instead of `IO.sysopen` ([#1912](https://github.com/ruby/rbs/pull/1912))
60
+
3
61
  ## 3.5.3 (2024-08-23)
4
62
 
5
63
  ### Library changes
data/Rakefile CHANGED
@@ -106,11 +106,17 @@ task :typecheck_test => :compile do
106
106
  end
107
107
 
108
108
  task :raap => :compile do
109
- sh %q[cat test/raap.txt | egrep -v '^#|^$' | xargs bundle exec raap]
109
+ sh %q[ruby test/raap.rb | xargs bundle exec raap -r digest/bubblebabble --library digest --allow-private]
110
110
  end
111
111
 
112
112
  task :rubocop do
113
- sh "rubocop --parallel"
113
+ format = if ENV["CI"]
114
+ "github"
115
+ else
116
+ "progress"
117
+ end
118
+
119
+ sh "rubocop --parallel --format #{format}"
114
120
  end
115
121
 
116
122
  namespace :generate do
data/core/array.rbs CHANGED
@@ -1082,7 +1082,7 @@ class Array[unchecked out Elem] < Object
1082
1082
  # a.at(0) # => :foo
1083
1083
  # a.at(2) # => 2
1084
1084
  #
1085
- def at: (int index) -> Elem?
1085
+ def at: %a{implicitly-returns-nil} (int index) -> Elem
1086
1086
 
1087
1087
  # <!--
1088
1088
  # rdoc-file=array.c
@@ -1378,7 +1378,7 @@ class Array[unchecked out Elem] < Object
1378
1378
  #
1379
1379
  # If `index` is too small (far from zero), returns nil.
1380
1380
  #
1381
- def delete_at: (int index) -> Elem?
1381
+ def delete_at: %a{implicitly-returns-nil} (int index) -> Elem
1382
1382
 
1383
1383
  # <!--
1384
1384
  # rdoc-file=array.c
@@ -1942,7 +1942,7 @@ class Array[unchecked out Elem] < Object
1942
1942
  #
1943
1943
  # Related: #last.
1944
1944
  #
1945
- def first: () -> Elem?
1945
+ def first: %a{implicitly-returns-nil} () -> Elem
1946
1946
  | (int n) -> ::Array[Elem]
1947
1947
 
1948
1948
  # <!--
@@ -2241,7 +2241,7 @@ class Array[unchecked out Elem] < Object
2241
2241
  #
2242
2242
  # Related: #first.
2243
2243
  #
2244
- def last: () -> Elem?
2244
+ def last: %a{implicitly-returns-nil} () -> Elem
2245
2245
  | (int n) -> ::Array[Elem]
2246
2246
 
2247
2247
  # <!--
@@ -2321,8 +2321,8 @@ class Array[unchecked out Elem] < Object
2321
2321
  #
2322
2322
  # ['0', '00', '000'].max(2) {|a, b| a.size <=> b.size } # => ["000", "00"]
2323
2323
  #
2324
- def max: () -> Elem?
2325
- | () { (Elem a, Elem b) -> ::Integer? } -> Elem?
2324
+ def max: %a{implicitly-returns-nil} () -> Elem
2325
+ | %a{implicitly-returns-nil} () { (Elem a, Elem b) -> ::Integer? } -> Elem
2326
2326
  | (int n) -> ::Array[Elem]
2327
2327
  | (int n) { (Elem a, Elem b) -> ::Integer? } -> ::Array[Elem]
2328
2328
 
@@ -3118,7 +3118,7 @@ class Array[unchecked out Elem] < Object
3118
3118
  # a.sample(random: Random.new(1)) #=> 6
3119
3119
  # a.sample(4, random: Random.new(1)) #=> [6, 10, 9, 2]
3120
3120
  #
3121
- def sample: (?random: _Rand rng) -> Elem?
3121
+ def sample: %a{implicitly-returns-nil} (?random: _Rand rng) -> Elem
3122
3122
  | (int n, ?random: _Rand rng) -> ::Array[Elem]
3123
3123
 
3124
3124
  # <!--
@@ -3197,7 +3197,7 @@ class Array[unchecked out Elem] < Object
3197
3197
  #
3198
3198
  # Related: #push, #pop, #unshift.
3199
3199
  #
3200
- def shift: () -> Elem?
3200
+ def shift: %a{implicitly-returns-nil} () -> Elem
3201
3201
  | (int n) -> ::Array[Elem]
3202
3202
 
3203
3203
  # <!--
@@ -3323,7 +3323,7 @@ class Array[unchecked out Elem] < Object
3323
3323
  # # Raises TypeError (no implicit conversion of Symbol into Integer):
3324
3324
  # a[:foo]
3325
3325
  #
3326
- def slice: (int index) -> Elem?
3326
+ def slice: %a{implicitly-returns-nil} (int index) -> Elem
3327
3327
  | (int start, int length) -> ::Array[Elem]?
3328
3328
  | (::Range[::Integer] range) -> ::Array[Elem]?
3329
3329
 
@@ -3393,7 +3393,7 @@ class Array[unchecked out Elem] < Object
3393
3393
  # a.slice!(-2..2) # => ["bar", 2]
3394
3394
  # a # => [:foo]
3395
3395
  #
3396
- def slice!: (int index) -> Elem?
3396
+ def slice!: %a{implicitly-returns-nil} (int index) -> Elem
3397
3397
  | (int start, int length) -> ::Array[Elem]?
3398
3398
  | (::Range[::Integer] range) -> ::Array[Elem]?
3399
3399
 
@@ -163,7 +163,7 @@ class BasicObject
163
163
  # k = Klass.new
164
164
  # k.send :hello, "gentle", "readers" #=> "Hello gentle readers"
165
165
  #
166
- def __send__: (interned name, *untyped, **untyped) ?{ (*untyped, **untyped) -> untyped } -> untyped
166
+ def __send__: (interned name, *untyped, **untyped) ?{ (?) -> untyped } -> untyped
167
167
 
168
168
  # <!-- rdoc-file=object.c -->
169
169
  # Equality --- At the Object level, #== returns `true` only if `obj` and `other`
@@ -248,7 +248,7 @@ class BasicObject
248
248
  # k = KlassWithSecret.new
249
249
  # k.instance_exec(5) {|x| @secret+x } #=> 104
250
250
  #
251
- def instance_exec: [U, V] (*V args) { (*V args) [self: self] -> U } -> U
251
+ def instance_exec: [U] (*untyped, **untyped) { (?) [self: self] -> U } -> U
252
252
 
253
253
  # <!--
254
254
  # rdoc-file=object.c
@@ -256,7 +256,7 @@ class BasicObject
256
256
  # -->
257
257
  # Returns a new BasicObject.
258
258
  #
259
- def initialize: () -> nil
259
+ def initialize: () -> void
260
260
 
261
261
  private
262
262
 
@@ -295,7 +295,7 @@ class BasicObject
295
295
  # r.mm #=> 2000
296
296
  # r.foo #=> NoMethodError
297
297
  #
298
- def method_missing: (Symbol, *untyped, **untyped) ?{ (*untyped, **untyped) -> untyped } -> untyped
298
+ def method_missing: (Symbol, *untyped, **untyped) ?{ (?) -> untyped } -> untyped
299
299
 
300
300
  # <!--
301
301
  # rdoc-file=object.c
data/core/builtin.rbs CHANGED
@@ -170,12 +170,12 @@ interface _Inspect
170
170
  def inspect: () -> String
171
171
  end
172
172
 
173
- interface _Each[out A]
174
- def each: () { (A) -> void } -> void
173
+ interface _Each[out E, out R = void]
174
+ def each: () { (E) -> void } -> R
175
175
  end
176
176
 
177
- interface _EachEntry[out A]
178
- def each_entry: () { (A) -> void } -> self
177
+ interface _EachEntry[out E]
178
+ def each_entry: () { (E) -> void } -> self
179
179
  end
180
180
 
181
181
  interface _Reader
data/core/dir.rbs CHANGED
@@ -182,7 +182,7 @@ class Dir
182
182
  # Dir.new('.').read.encoding # => #<Encoding:UTF-8>
183
183
  # Dir.new('.', encoding: 'US-ASCII').read.encoding # => #<Encoding:US-ASCII>
184
184
  #
185
- def initialize: (path dir, ?encoding: encoding?) -> self
185
+ def initialize: (path dir, ?encoding: encoding?) -> void
186
186
 
187
187
  # <!--
188
188
  # rdoc-file=dir.rb
data/core/enumerable.rbs CHANGED
@@ -528,6 +528,12 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
528
528
  #
529
529
  def entries: () -> ::Array[Elem]
530
530
 
531
+ def enum_for: (Symbol method, *untyped, **untyped) ?{ (?) -> Integer } -> Enumerator[untyped, untyped]
532
+ | () ?{ () -> Integer } -> Enumerator[Elem, self]
533
+
534
+ %a{annotate:rdoc:skip}
535
+ alias to_enum enum_for
536
+
531
537
  # <!--
532
538
  # rdoc-file=enum.c
533
539
  # - select {|element| ... } -> array
@@ -1293,7 +1299,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1293
1299
  # With no block given, returns an Enumerator.
1294
1300
  #
1295
1301
  def reverse_each: () { (Elem arg0) -> untyped } -> void
1296
- | () -> ::Enumerator[Elem, void]
1302
+ | () -> ::Enumerator[Elem]
1297
1303
 
1298
1304
  # <!--
1299
1305
  # rdoc-file=enum.c
@@ -1754,7 +1760,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1754
1760
  # # show pythagorean triples less than 100
1755
1761
  # p pythagorean_triples.take_while { |*, z| z < 100 }.force
1756
1762
  #
1757
- def lazy: () -> Enumerator::Lazy[Elem, void]
1763
+ def lazy: () -> Enumerator::Lazy[Elem]
1758
1764
 
1759
1765
  # <!--
1760
1766
  # rdoc-file=enum.c
@@ -1840,7 +1846,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
1840
1846
  # e = (1..3).chain([4, 5])
1841
1847
  # e.to_a #=> [1, 2, 3, 4, 5]
1842
1848
  #
1843
- def chain: (*self enumerables) -> ::Enumerator::Chain[Elem]
1849
+ def chain: [Elem2] (*_Each[Elem2] enumerables) -> ::Enumerator::Chain[Elem | Elem2]
1844
1850
 
1845
1851
  # <!--
1846
1852
  # rdoc-file=enum.c
@@ -2086,8 +2092,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2086
2092
  # pp lines
2087
2093
  # }
2088
2094
  #
2089
- def chunk: [U] () { (Elem elt) -> U } -> ::Enumerator[[ U, ::Array[Elem] ], void]
2090
- | () -> ::Enumerator[Elem, ::Enumerator[[ untyped, ::Array[Elem] ], void]]
2095
+ def chunk: [U] () { (Elem elt) -> U } -> ::Enumerator[[ U, ::Array[Elem] ]]
2096
+ | () -> ::Enumerator[Elem, ::Enumerator[[ untyped, ::Array[Elem] ]]]
2091
2097
 
2092
2098
  # <!--
2093
2099
  # rdoc-file=enum.c
@@ -2136,7 +2142,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2136
2142
  # Enumerable#slice_when does the same, except splitting when the block returns
2137
2143
  # `true` instead of `false`.
2138
2144
  #
2139
- def chunk_while: () { (Elem elt_before, Elem elt_after) -> boolish } -> ::Enumerator[::Array[Elem], void]
2145
+ def chunk_while: () { (Elem elt_before, Elem elt_after) -> boolish } -> ::Enumerator[::Array[Elem]]
2140
2146
 
2141
2147
  # <!--
2142
2148
  # rdoc-file=enum.c
@@ -2198,7 +2204,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2198
2204
  # Enumerable#chunk_while does the same, except splitting when the block returns
2199
2205
  # `false` instead of `true`.
2200
2206
  #
2201
- def slice_when: () { (Elem elt_before, Elem elt_after) -> boolish } -> ::Enumerator[::Array[Elem], void]
2207
+ def slice_when: () { (Elem elt_before, Elem elt_after) -> boolish } -> ::Enumerator[::Array[Elem]]
2202
2208
 
2203
2209
  # <!--
2204
2210
  # rdoc-file=enum.c
@@ -2233,8 +2239,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2233
2239
  # p e.map {|ll| ll[0...-1].map {|l| l.sub(/\\\n\z/, "") }.join + ll.last }
2234
2240
  # #=>["foo\n", "barbaz\n", "\n", "qux\n"]
2235
2241
  #
2236
- def slice_after: (untyped pattern) -> ::Enumerator[::Array[Elem], void]
2237
- | () { (Elem elt) -> boolish } -> ::Enumerator[::Array[Elem], void]
2242
+ def slice_after: (untyped pattern) -> ::Enumerator[::Array[Elem]]
2243
+ | () { (Elem elt) -> boolish } -> ::Enumerator[::Array[Elem]]
2238
2244
 
2239
2245
  # <!--
2240
2246
  # rdoc-file=enum.c
@@ -2390,6 +2396,6 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
2390
2396
  # }
2391
2397
  # }
2392
2398
  #
2393
- def slice_before: (untyped pattern) -> ::Enumerator[::Array[Elem], void]
2394
- | () { (Elem elt) -> boolish } -> ::Enumerator[::Array[Elem], void]
2399
+ def slice_before: (untyped pattern) -> ::Enumerator[::Array[Elem]]
2400
+ | () { (Elem elt) -> boolish } -> ::Enumerator[::Array[Elem]]
2395
2401
  end
@@ -1,5 +1,5 @@
1
1
  %a{annotate:rdoc:skip}
2
- class Enumerator[unchecked out Elem, out Return]
2
+ class Enumerator[unchecked out Elem, out Return = void]
3
3
  # <!-- rdoc-file=enumerator.c -->
4
4
  # Enumerator::Product generates a Cartesian product of any number of enumerable
5
5
  # objects. Iterating over the product of enumerable objects is roughly
data/core/enumerator.rbs CHANGED
@@ -127,9 +127,16 @@
127
127
  # puts ext_each(o.to_enum) {|*x| puts x; [:b, *x] }
128
128
  # # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3
129
129
  #
130
- class Enumerator[unchecked out Elem, out Return] < Object
130
+ class Enumerator[unchecked out Elem, out Return = void] < Object
131
131
  include Enumerable[Elem]
132
132
 
133
+ # A convenience interface for `each` with optional block
134
+ #
135
+ interface _Each[out E, out R = self]
136
+ def each: () { (E) -> void } -> R
137
+ | () -> Enumerator[E, R]
138
+ end
139
+
133
140
  # <!--
134
141
  # rdoc-file=enumerator.c
135
142
  # - Enumerator.produce(initial = nil) { |prev| block } -> enumerator
@@ -560,7 +567,7 @@ end
560
567
  # # This returns an array of items like a normal enumerator does.
561
568
  # all_checked = active_items.select(&:checked)
562
569
  #
563
- class Enumerator::Lazy[out Elem, out Return] < Enumerator[Elem, Return]
570
+ class Enumerator::Lazy[out Elem, out Return = void] < Enumerator[Elem, Return]
564
571
  # <!-- rdoc-file=enumerator.c -->
565
572
  # Expands `lazy` enumerator to an array. See Enumerable#to_a.
566
573
  #
data/core/errors.rbs CHANGED
@@ -597,7 +597,7 @@ class SystemCallError < StandardError
597
597
  # SystemCallError object. The error number is subsequently available via the
598
598
  # #errno method.
599
599
  #
600
- def initialize: (string msg, Integer errno) -> SystemCallError
600
+ def initialize: (string msg, Integer errno) -> void
601
601
 
602
602
  # <!--
603
603
  # rdoc-file=error.c
data/core/exception.rbs CHANGED
@@ -250,7 +250,7 @@ class Exception
250
250
  # -->
251
251
  # Construct a new Exception object, optionally passing in a message.
252
252
  #
253
- def initialize: (?string | _ToS message) -> self
253
+ def initialize: (?string | _ToS message) -> void
254
254
 
255
255
  # <!--
256
256
  # rdoc-file=error.c
data/core/fiber.rbs CHANGED
@@ -268,7 +268,7 @@ class Fiber < Object
268
268
  # Explicitly using `storage: true` is currently experimental and may change in
269
269
  # the future.
270
270
  #
271
- def initialize: (?blocking: boolish, ?storage: true | Hash[interned, untyped] | nil) { (*untyped) -> void } -> void
271
+ def initialize: (?blocking: boolish, ?storage: true | Hash[interned, untyped] | nil) { (?) -> void } -> void
272
272
 
273
273
  # <!--
274
274
  # rdoc-file=cont.c
data/core/file.rbs CHANGED
@@ -875,7 +875,7 @@ class File < IO
875
875
  # * [Open Options](rdoc-ref:IO@Open+Options).
876
876
  # * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
877
877
  #
878
- def initialize: (string | _ToPath | int file_name, ?string | int mode, ?int perm) -> File
878
+ def initialize: (string | _ToPath | int file_name, ?string | int mode, ?int perm) -> void
879
879
 
880
880
  # <!--
881
881
  # rdoc-file=file.c
@@ -118,7 +118,7 @@ $;: Regexp | String | nil
118
118
  $<: RBS::Unnamed::ARGFClass
119
119
 
120
120
  # This variable is no longer effective. Deprecated.
121
- $=: bool
121
+ $=: false
122
122
 
123
123
  # The default output stream for Kernel#print and Kernel#printf. $stdout by default.
124
124
  $>: IO
@@ -150,7 +150,7 @@ $LOADED_FEATURES: Array[String]
150
150
  $LOAD_PATH: Array[String] & _LoadPathAPI
151
151
 
152
152
  interface _LoadPathAPI
153
- def resolve_feature_path: (String) -> [:rb | :so, String]?
153
+ def resolve_feature_path: (path feature_path) -> [:rb | :so, String]?
154
154
  end
155
155
 
156
156
  # Contains the name of the script being executed. May be assignable.
data/core/integer.rbs CHANGED
@@ -1168,10 +1168,10 @@ class Integer < Numeric
1168
1168
  | (to: Numeric, ?by: Integer) { (Integer) -> void } -> void
1169
1169
  | (by: Numeric, ?to: Numeric) { (Numeric) -> void } -> void
1170
1170
  | () -> Enumerator[Integer, bot]
1171
- | (Numeric limit, ?Integer step) -> Enumerator[Integer, void]
1172
- | (Numeric limit, ?Numeric step) -> Enumerator[Numeric, void]
1173
- | (to: Numeric, ?by: Integer) -> Enumerator[Integer, void]
1174
- | (by: Numeric, ?to: Numeric) -> Enumerator[Numeric, void]
1171
+ | (Numeric limit, ?Integer step) -> Enumerator[Integer]
1172
+ | (Numeric limit, ?Numeric step) -> Enumerator[Numeric]
1173
+ | (to: Numeric, ?by: Integer) -> Enumerator[Integer]
1174
+ | (by: Numeric, ?to: Numeric) -> Enumerator[Numeric]
1175
1175
 
1176
1176
  # <!--
1177
1177
  # rdoc-file=numeric.c