rbs 3.5.1 → 3.6.1

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 (146) 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 +123 -0
  7. data/Rakefile +10 -4
  8. data/core/array.rbs +10 -12
  9. data/core/basic_object.rbs +4 -4
  10. data/core/builtin.rbs +4 -4
  11. data/core/complex.rbs +0 -2
  12. data/core/data.rbs +0 -2
  13. data/core/dir.rbs +1 -3
  14. data/core/encoding.rbs +0 -2
  15. data/core/enumerable.rbs +17 -11
  16. data/core/enumerator/product.rbs +1 -3
  17. data/core/enumerator.rbs +9 -2
  18. data/core/errors.rbs +1 -13
  19. data/core/exception.rbs +1 -1
  20. data/core/fiber.rbs +1 -1
  21. data/core/file.rbs +1 -3
  22. data/core/float.rbs +0 -2
  23. data/core/global_variables.rbs +2 -2
  24. data/core/hash.rbs +0 -2
  25. data/core/integer.rbs +4 -6
  26. data/core/io/buffer.rbs +0 -2
  27. data/core/kernel.rbs +68 -39
  28. data/core/method.rbs +98 -7
  29. data/core/module.rbs +5 -5
  30. data/core/numeric.rbs +0 -2
  31. data/core/object_space/weak_key_map.rbs +0 -2
  32. data/core/proc.rbs +184 -23
  33. data/core/ractor.rbs +1 -7
  34. data/core/random.rbs +1 -1
  35. data/core/range.rbs +30 -0
  36. data/core/rational.rbs +0 -2
  37. data/core/rbs/unnamed/argf.rbs +0 -2
  38. data/core/rbs/unnamed/env_class.rbs +7 -7
  39. data/core/rbs/unnamed/random.rbs +14 -14
  40. data/core/refinement.rbs +16 -26
  41. data/core/regexp.rbs +2 -2
  42. data/core/ruby_vm.rbs +305 -0
  43. data/core/rubygems/errors.rbs +66 -0
  44. data/core/rubygems/rubygems.rbs +66 -0
  45. data/core/string.rbs +4 -0
  46. data/core/symbol.rbs +34 -26
  47. data/core/thread.rbs +8 -7
  48. data/core/trace_point.rbs +12 -12
  49. data/core/unbound_method.rbs +1 -1
  50. data/docs/syntax.md +26 -12
  51. data/ext/rbs_extension/lexer.c +1 -1
  52. data/ext/rbs_extension/lexer.h +5 -0
  53. data/ext/rbs_extension/lexer.re +1 -1
  54. data/ext/rbs_extension/lexstate.c +16 -0
  55. data/ext/rbs_extension/location.c +27 -39
  56. data/ext/rbs_extension/location.h +7 -2
  57. data/ext/rbs_extension/main.c +3 -0
  58. data/ext/rbs_extension/parser.c +135 -55
  59. data/ext/rbs_extension/parserstate.c +2 -7
  60. data/ext/rbs_extension/parserstate.h +6 -5
  61. data/ext/rbs_extension/ruby_objs.c +2 -1
  62. data/ext/rbs_extension/ruby_objs.h +1 -1
  63. data/lib/rbs/ast/declarations.rb +36 -0
  64. data/lib/rbs/ast/type_param.rb +104 -15
  65. data/lib/rbs/ast/visitor.rb +137 -0
  66. data/lib/rbs/buffer.rb +5 -0
  67. data/lib/rbs/cli/validate.rb +83 -7
  68. data/lib/rbs/cli.rb +3 -3
  69. data/lib/rbs/definition.rb +2 -7
  70. data/lib/rbs/definition_builder/ancestor_builder.rb +51 -9
  71. data/lib/rbs/definition_builder.rb +28 -12
  72. data/lib/rbs/environment_loader.rb +1 -1
  73. data/lib/rbs/errors.rb +46 -3
  74. data/lib/rbs/file_finder.rb +9 -12
  75. data/lib/rbs/location_aux.rb +2 -6
  76. data/lib/rbs/locator.rb +8 -5
  77. data/lib/rbs/prototype/rb.rb +2 -2
  78. data/lib/rbs/prototype/rbi.rb +2 -1
  79. data/lib/rbs/prototype/runtime.rb +3 -2
  80. data/lib/rbs/sorter.rb +9 -6
  81. data/lib/rbs/test/type_check.rb +13 -0
  82. data/lib/rbs/types.rb +12 -1
  83. data/lib/rbs/validator.rb +2 -2
  84. data/lib/rbs/vendorer.rb +3 -3
  85. data/lib/rbs/version.rb +1 -1
  86. data/lib/rbs.rb +1 -0
  87. data/sig/declarations.rbs +6 -0
  88. data/sig/definition.rbs +2 -2
  89. data/sig/definition_builder.rbs +3 -1
  90. data/sig/errors.rbs +17 -2
  91. data/sig/file_finder.rbs +24 -2
  92. data/sig/location.rbs +0 -3
  93. data/sig/members.rbs +1 -2
  94. data/sig/method_types.rbs +1 -1
  95. data/sig/sorter.rbs +1 -1
  96. data/sig/type_param.rbs +45 -9
  97. data/sig/types.rbs +24 -5
  98. data/sig/visitor.rbs +47 -0
  99. data/stdlib/bigdecimal/0/big_decimal.rbs +0 -2
  100. data/stdlib/cgi/0/core.rbs +0 -10
  101. data/stdlib/csv/0/csv.rbs +44 -6
  102. data/stdlib/date/0/date.rbs +0 -2
  103. data/stdlib/date/0/date_time.rbs +0 -2
  104. data/stdlib/dbm/0/dbm.rbs +0 -2
  105. data/stdlib/delegate/0/delegator.rbs +0 -2
  106. data/stdlib/delegate/0/simple_delegator.rbs +0 -2
  107. data/stdlib/digest/0/digest.rbs +22 -32
  108. data/stdlib/etc/0/etc.rbs +0 -4
  109. data/stdlib/ipaddr/0/ipaddr.rbs +1 -1
  110. data/stdlib/json/0/json.rbs +22 -0
  111. data/stdlib/kconv/0/kconv.rbs +166 -0
  112. data/stdlib/logger/0/formatter.rbs +0 -2
  113. data/stdlib/logger/0/log_device.rbs +0 -2
  114. data/stdlib/logger/0/logger.rbs +0 -2
  115. data/stdlib/monitor/0/monitor.rbs +0 -6
  116. data/stdlib/mutex_m/0/mutex_m.rbs +0 -2
  117. data/stdlib/net-http/0/net-http.rbs +2 -10
  118. data/stdlib/observable/0/observable.rbs +0 -2
  119. data/stdlib/open-uri/0/open-uri.rbs +1 -1
  120. data/stdlib/open3/0/open3.rbs +155 -0
  121. data/stdlib/openssl/0/openssl.rbs +0 -112
  122. data/stdlib/optparse/0/optparse.rbs +0 -22
  123. data/stdlib/pathname/0/pathname.rbs +0 -2
  124. data/stdlib/pstore/0/pstore.rbs +0 -2
  125. data/stdlib/psych/0/store.rbs +1 -1
  126. data/stdlib/resolv/0/resolv.rbs +0 -74
  127. data/stdlib/singleton/0/singleton.rbs +0 -2
  128. data/stdlib/socket/0/addrinfo.rbs +0 -2
  129. data/stdlib/socket/0/basic_socket.rbs +0 -2
  130. data/stdlib/socket/0/ip_socket.rbs +0 -2
  131. data/stdlib/socket/0/socket.rbs +0 -8
  132. data/stdlib/socket/0/tcp_server.rbs +0 -2
  133. data/stdlib/socket/0/udp_socket.rbs +0 -2
  134. data/stdlib/socket/0/unix_server.rbs +0 -2
  135. data/stdlib/socket/0/unix_socket.rbs +0 -2
  136. data/stdlib/strscan/0/string_scanner.rbs +4 -6
  137. data/stdlib/tempfile/0/tempfile.rbs +0 -4
  138. data/stdlib/uri/0/ldap.rbs +1 -1
  139. data/stdlib/zlib/0/deflate.rbs +1 -3
  140. data/stdlib/zlib/0/gzip_file/error.rbs +0 -2
  141. data/stdlib/zlib/0/gzip_file.rbs +0 -2
  142. data/stdlib/zlib/0/gzip_reader.rbs +5 -3
  143. data/stdlib/zlib/0/gzip_writer.rbs +0 -2
  144. data/stdlib/zlib/0/inflate.rbs +0 -2
  145. data/stdlib/zlib/0/zstream.rbs +0 -2
  146. metadata +8 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3dc7a972ca885618f8bcb3beb35d5096ddd9cc3dc6880fb6ae6b06d4a1845be0
4
- data.tar.gz: 3fd84cf6a4869385f16e98cb1319855fcc1fcc242e16731b6bbdd5d249f1df8a
3
+ metadata.gz: cd93b9bdce0e6148409689ba4aa2db4d34109e46b799706b6f44944134f1b817
4
+ data.tar.gz: 3780dcddba54316cf7cb97224f7dc7a187195904a3f21cc430a017c03d663387
5
5
  SHA512:
6
- metadata.gz: 0b79dcac9fa9f94eff95b2c098208784f45e8ee891b94202f8e82886d15e0af04bbb26acdff5428277470536cfef164f79b5a1f73ded288b320600bd15568500
7
- data.tar.gz: c0c6f53213e0b0aac09747c2aef470548b2b872b8ace2647ebdedca292a55b8aa0dbbebfa5c3ff75c47d3f76e87643f23f75883cacc49726fd778f95e1c3ee9e
6
+ metadata.gz: 786d469a57422f169e2980a4b0f80eb4ec857081f51b2c56ac87e070abd118b4245f537457de06058ef32ea394742e9bcb3cd106c7d3408b51a0aab8a622a260
7
+ data.tar.gz: 7b70ac096f7d53171b5aebcafc6605426e80ee598cddabb70c520b689cc07fadbaa22bda3d2bd9f6a748587cc6ce11246c3a79f50125ea102cf561ed66bfc353
@@ -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,128 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 3.6.1 (2024-10-03)
4
+
5
+ ### Library changes
6
+
7
+ * Mark as ractor-safe ([#2041](https://github.com/ruby/rbs/pull/2041))
8
+
9
+ ### Miscellaneous
10
+
11
+ * Omit IOConsoleTest with Windows platform ([#2044](https://github.com/ruby/rbs/pull/2044))
12
+ * Recover `$stdout` after test ([#2042](https://github.com/ruby/rbs/pull/2042))
13
+
14
+ ## 3.6.0 (2024-09-30)
15
+
16
+ Nothing changed since `3.6.0.pre.3`.
17
+
18
+ ## 3.6.0.pre.3 (2024-09-30)
19
+
20
+ ### Signature updates
21
+
22
+ * `JSON.load_file`, `.load_file!` ([#2031](https://github.com/ruby/rbs/pull/2031))
23
+ * `Module#class_eval`, `Module#module_eval` ([#2029](https://github.com/ruby/rbs/pull/2029))
24
+ * `Open3` ([#2014](https://github.com/ruby/rbs/pull/2014))
25
+ * `RubyVM::InstructionSequence` ([#2027](https://github.com/ruby/rbs/pull/2027))
26
+ * Fixup RBS type definitions with rbs-on-rubocop ([#2023](https://github.com/ruby/rbs/pull/2023))
27
+ * Avoid using `instance`/`class` types in modules ([#2020](https://github.com/ruby/rbs/pull/2020))
28
+
29
+ ### Language updates
30
+
31
+ * Optional type param restriction ([#2030](https://github.com/ruby/rbs/pull/2030))
32
+ * Prohibit `self` type as a generics default ([#2022](https://github.com/ruby/rbs/pull/2022))
33
+ * Allow `self` types in generics default type ([#2021](https://github.com/ruby/rbs/pull/2021))
34
+
35
+ ### Library changes
36
+
37
+ * Add `TypeParamDefaultReferenceError#type_param` ([#2032](https://github.com/ruby/rbs/pull/2032))
38
+
39
+ ## 3.6.0.pre.2 (2024-09-18)
40
+
41
+ ### Signature updates
42
+
43
+ * `Kernel#class` ([#2017](https://github.com/ruby/rbs/pull/2017))
44
+ * `TracePoint#enable` ([#2015](https://github.com/ruby/rbs/pull/2015))
45
+
46
+ ### Miscellaneous
47
+
48
+ * Fix type definition and type errors ([#2016](https://github.com/ruby/rbs/pull/2016))
49
+
50
+ ## 3.6.0.pre.1 (2024-09-17)
51
+
52
+ ### Signature updates
53
+
54
+ * 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))
55
+ * digest ([#1880](https://github.com/ruby/rbs/pull/1880))
56
+ * kconv ([#1857](https://github.com/ruby/rbs/pull/1857))
57
+ * zlib ([#1911](https://github.com/ruby/rbs/pull/1911))
58
+ * `_Each` ([#2006](https://github.com/ruby/rbs/pull/2006))
59
+ * `Array` ([#1921](https://github.com/ruby/rbs/pull/1921))
60
+ * `Enumerable` ([#1921](https://github.com/ruby/rbs/pull/1921))
61
+ * `Enumerator::_Each` ([#2006](https://github.com/ruby/rbs/pull/2006), [#1915](https://github.com/ruby/rbs/pull/1915))
62
+ * `Enumerator` ([#2004](https://github.com/ruby/rbs/pull/2004))
63
+ * `Kernel` ([#1945](https://github.com/ruby/rbs/pull/1945))
64
+ * `Method` ([#1939](https://github.com/ruby/rbs/pull/1939))
65
+ * `Module` ([#1921](https://github.com/ruby/rbs/pull/1921))
66
+ * `Net::HTTPHeader` ([#1932](https://github.com/ruby/rbs/pull/1932))
67
+ * `Proc` ([#1937](https://github.com/ruby/rbs/pull/1937))
68
+ * `Queue` ([#2004](https://github.com/ruby/rbs/pull/2004))
69
+ * `Range` ([#1921](https://github.com/ruby/rbs/pull/1921))
70
+ * `Refinement` ([#1931](https://github.com/ruby/rbs/pull/1931))
71
+ * `Symbol` ([#1930](https://github.com/ruby/rbs/pull/1930))
72
+ * `TracePoint` ([#1943](https://github.com/ruby/rbs/pull/1943))
73
+ * `#rand` ([#2007](https://github.com/ruby/rbs/pull/2007))
74
+ * Use untyped blocks ([#1935](https://github.com/ruby/rbs/pull/1935))
75
+ * Update docs for ruby-3.3.4 ([#1923](https://github.com/ruby/rbs/pull/1923))
76
+ * Update docs for ruby-3.3.3 ([#1889](https://github.com/ruby/rbs/pull/1889))
77
+
78
+ ### Language updates
79
+
80
+ * Fix position for default_type ([#1997](https://github.com/ruby/rbs/pull/1997))
81
+ * Update `syntax.md` ([#1995](https://github.com/ruby/rbs/pull/1995))
82
+ * Improve generics ([#1994](https://github.com/ruby/rbs/pull/1994))
83
+ * Allow alias to module-self-type from module ([#1948](https://github.com/ruby/rbs/pull/1948))
84
+ * Make it a syntax error when the keys of keyword and record are duplicated. ([#1883](https://github.com/ruby/rbs/pull/1883))
85
+
86
+ ### Library changes
87
+
88
+ * Omit unnecessary field from location range ([#1788](https://github.com/ruby/rbs/pull/1788))
89
+ * Handle ISEQs compiled by Prism ([#1983](https://github.com/ruby/rbs/pull/1983))
90
+ * Add AST Visitor ([#1975](https://github.com/ruby/rbs/pull/1975))
91
+ * Make the extension `GC.auto_compact` compatible ([#1971](https://github.com/ruby/rbs/pull/1971))
92
+ * Make `FileFinder` faster by globbing all possible files ([#1965](https://github.com/ruby/rbs/pull/1965))
93
+ * Fix #1905: Fix typo in `UntypedFunction` ([#1906](https://github.com/ruby/rbs/pull/1906))
94
+
95
+ #### rbs prototype
96
+
97
+ * [prototype] Remove redundant access modifier ([#1914](https://github.com/ruby/rbs/pull/1914))
98
+
99
+ ### Miscellaneous
100
+
101
+ * Allow RBS/Style/InitializeReturnType ([#2008](https://github.com/ruby/rbs/pull/2008))
102
+ * docs: An interface can include interfaces only and not modules ([#1996](https://github.com/ruby/rbs/pull/1996))
103
+ * Fix the portability of an external command ([#2001](https://github.com/ruby/rbs/pull/2001))
104
+ * Skip `AbstractSyntaxTree` test with ruby-3.4 ([#2005](https://github.com/ruby/rbs/pull/2005))
105
+ * Fix test ([#1972](https://github.com/ruby/rbs/pull/1972))
106
+ * Use `File.open` instead of `IO.sysopen` ([#1912](https://github.com/ruby/rbs/pull/1912))
107
+
108
+ ## 3.5.3 (2024-08-23)
109
+
110
+ ### Library changes
111
+
112
+ * Backport GC fix PR ([#1977](https://github.com/ruby/rbs/pull/1977))
113
+
114
+ ## 3.5.2 (2024-07-10)
115
+
116
+ ### Library changes
117
+
118
+ * Update docs for ruby-3.3.4 ([#1923](https://github.com/ruby/rbs/pull/1923), Backported in [#1925](https://github.com/ruby/rbs/pull/1925))
119
+ * Update docs for ruby-3.3.3 ([#1889](https://github.com/ruby/rbs/pull/1889), Backported in [#1925](https://github.com/ruby/rbs/pull/1925))
120
+ * Fix #1905: Fix typo in `UntypedFunction` ([#1906](https://github.com/ruby/rbs/pull/1906), Backported in [#1925](https://github.com/ruby/rbs/pull/1925))
121
+
122
+ ### Miscellaneous
123
+
124
+ * Use `File.open` instead of `IO.sysopen` ([#1913](https://github.com/ruby/rbs/pull/1913))
125
+
3
126
  ## 3.5.1 (2024-06-07)
4
127
 
5
128
  ### Library changes
data/Rakefile CHANGED
@@ -56,7 +56,7 @@ end
56
56
  task :validate => :compile do
57
57
  require 'yaml'
58
58
 
59
- sh "#{ruby} #{rbs} validate"
59
+ sh "#{ruby} #{rbs} validate --exit-error-on-syntax-error"
60
60
 
61
61
  libs = FileList["stdlib/*"].map {|path| File.basename(path).to_s }
62
62
 
@@ -72,7 +72,7 @@ task :validate => :compile do
72
72
  end
73
73
 
74
74
  libs.each do |lib|
75
- sh "#{ruby} #{rbs} -r #{lib} validate"
75
+ sh "#{ruby} #{rbs} -r #{lib} validate --exit-error-on-syntax-error"
76
76
  end
77
77
  end
78
78
 
@@ -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
@@ -600,8 +600,6 @@ class Array[unchecked out Elem] < Object
600
600
  #
601
601
  def self.try_convert: [U] (untyped) -> ::Array[U]?
602
602
 
603
- public
604
-
605
603
  # <!--
606
604
  # rdoc-file=array.c
607
605
  # - array & other_array -> new_array
@@ -1082,7 +1080,7 @@ class Array[unchecked out Elem] < Object
1082
1080
  # a.at(0) # => :foo
1083
1081
  # a.at(2) # => 2
1084
1082
  #
1085
- def at: (int index) -> Elem?
1083
+ def at: %a{implicitly-returns-nil} (int index) -> Elem
1086
1084
 
1087
1085
  # <!--
1088
1086
  # rdoc-file=array.c
@@ -1378,7 +1376,7 @@ class Array[unchecked out Elem] < Object
1378
1376
  #
1379
1377
  # If `index` is too small (far from zero), returns nil.
1380
1378
  #
1381
- def delete_at: (int index) -> Elem?
1379
+ def delete_at: %a{implicitly-returns-nil} (int index) -> Elem
1382
1380
 
1383
1381
  # <!--
1384
1382
  # rdoc-file=array.c
@@ -1942,7 +1940,7 @@ class Array[unchecked out Elem] < Object
1942
1940
  #
1943
1941
  # Related: #last.
1944
1942
  #
1945
- def first: () -> Elem?
1943
+ def first: %a{implicitly-returns-nil} () -> Elem
1946
1944
  | (int n) -> ::Array[Elem]
1947
1945
 
1948
1946
  # <!--
@@ -2241,7 +2239,7 @@ class Array[unchecked out Elem] < Object
2241
2239
  #
2242
2240
  # Related: #first.
2243
2241
  #
2244
- def last: () -> Elem?
2242
+ def last: %a{implicitly-returns-nil} () -> Elem
2245
2243
  | (int n) -> ::Array[Elem]
2246
2244
 
2247
2245
  # <!--
@@ -2321,8 +2319,8 @@ class Array[unchecked out Elem] < Object
2321
2319
  #
2322
2320
  # ['0', '00', '000'].max(2) {|a, b| a.size <=> b.size } # => ["000", "00"]
2323
2321
  #
2324
- def max: () -> Elem?
2325
- | () { (Elem a, Elem b) -> ::Integer? } -> Elem?
2322
+ def max: %a{implicitly-returns-nil} () -> Elem
2323
+ | %a{implicitly-returns-nil} () { (Elem a, Elem b) -> ::Integer? } -> Elem
2326
2324
  | (int n) -> ::Array[Elem]
2327
2325
  | (int n) { (Elem a, Elem b) -> ::Integer? } -> ::Array[Elem]
2328
2326
 
@@ -3118,7 +3116,7 @@ class Array[unchecked out Elem] < Object
3118
3116
  # a.sample(random: Random.new(1)) #=> 6
3119
3117
  # a.sample(4, random: Random.new(1)) #=> [6, 10, 9, 2]
3120
3118
  #
3121
- def sample: (?random: _Rand rng) -> Elem?
3119
+ def sample: %a{implicitly-returns-nil} (?random: _Rand rng) -> Elem
3122
3120
  | (int n, ?random: _Rand rng) -> ::Array[Elem]
3123
3121
 
3124
3122
  # <!--
@@ -3197,7 +3195,7 @@ class Array[unchecked out Elem] < Object
3197
3195
  #
3198
3196
  # Related: #push, #pop, #unshift.
3199
3197
  #
3200
- def shift: () -> Elem?
3198
+ def shift: %a{implicitly-returns-nil} () -> Elem
3201
3199
  | (int n) -> ::Array[Elem]
3202
3200
 
3203
3201
  # <!--
@@ -3323,7 +3321,7 @@ class Array[unchecked out Elem] < Object
3323
3321
  # # Raises TypeError (no implicit conversion of Symbol into Integer):
3324
3322
  # a[:foo]
3325
3323
  #
3326
- def slice: (int index) -> Elem?
3324
+ def slice: %a{implicitly-returns-nil} (int index) -> Elem
3327
3325
  | (int start, int length) -> ::Array[Elem]?
3328
3326
  | (::Range[::Integer] range) -> ::Array[Elem]?
3329
3327
 
@@ -3393,7 +3391,7 @@ class Array[unchecked out Elem] < Object
3393
3391
  # a.slice!(-2..2) # => ["bar", 2]
3394
3392
  # a # => [:foo]
3395
3393
  #
3396
- def slice!: (int index) -> Elem?
3394
+ def slice!: %a{implicitly-returns-nil} (int index) -> Elem
3397
3395
  | (int start, int length) -> ::Array[Elem]?
3398
3396
  | (::Range[::Integer] range) -> ::Array[Elem]?
3399
3397
 
@@ -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/complex.rbs CHANGED
@@ -109,8 +109,6 @@ class Complex < Numeric
109
109
  #
110
110
  alias self.rectangular self.rect
111
111
 
112
- public
113
-
114
112
  # <!--
115
113
  # rdoc-file=complex.c
116
114
  # - complex * numeric -> new_complex
data/core/data.rbs CHANGED
@@ -183,8 +183,6 @@ class Data
183
183
 
184
184
  def self.allocate: () -> bot
185
185
 
186
- public
187
-
188
186
  # <!--
189
187
  # rdoc-file=struct.c
190
188
  # - self == other -> true or false
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
@@ -759,8 +759,6 @@ class Dir
759
759
  #
760
760
  alias self.unlink self.delete
761
761
 
762
- public
763
-
764
762
  # <!--
765
763
  # rdoc-file=dir.c
766
764
  # - chdir -> 0
data/core/encoding.rbs CHANGED
@@ -780,8 +780,6 @@ class Encoding::Converter < Object
780
780
  ?xml: :text | :attr
781
781
  ) -> conversion_path
782
782
 
783
- public
784
-
785
783
  # <!--
786
784
  # rdoc-file=transcode.c
787
785
  # - ec == other -> true or false
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
@@ -44,8 +44,6 @@ class Enumerator[unchecked out Elem, out Return]
44
44
  #
45
45
  def initialize: (*_EachEntry[Elem]) -> void
46
46
 
47
- public
48
-
49
47
  # <!--
50
48
  # rdoc-file=enumerator.c
51
49
  # - obj.each { |...| ... } -> obj
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]
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
  #