rbs 3.8.1 → 3.9.2
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.
- checksums.yaml +4 -4
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/ruby.yml +26 -0
- data/.github/workflows/typecheck.yml +2 -0
- data/.github/workflows/windows.yml +15 -0
- data/.rubocop.yml +13 -1
- data/CHANGELOG.md +80 -0
- data/Rakefile +20 -3
- data/config.yml +6 -0
- data/core/data.rbs +1 -1
- data/core/enumerator.rbs +14 -2
- data/core/exception.rbs +1 -1
- data/core/gc.rbs +1 -1
- data/core/hash.rbs +2 -2
- data/core/io.rbs +7 -3
- data/core/kernel.rbs +4 -4
- data/core/method.rbs +2 -2
- data/core/module.rbs +4 -4
- data/core/object.rbs +1 -1
- data/core/proc.rbs +2 -2
- data/core/rbs/unnamed/argf.rbs +3 -3
- data/core/rubygems/version.rbs +2 -2
- data/core/string.rbs +3 -3
- data/core/unbound_method.rbs +1 -1
- data/docs/syntax.md +10 -5
- data/ext/rbs_extension/extconf.rb +2 -1
- data/ext/rbs_extension/location.c +32 -10
- data/ext/rbs_extension/location.h +4 -3
- data/ext/rbs_extension/main.c +22 -1
- data/ext/rbs_extension/parser.c +171 -150
- data/ext/rbs_extension/parserstate.c +54 -9
- data/ext/rbs_extension/parserstate.h +6 -4
- data/include/rbs/ruby_objs.h +6 -6
- data/include/rbs/util/rbs_constant_pool.h +219 -0
- data/lib/rbs/ast/declarations.rb +9 -4
- data/lib/rbs/ast/directives.rb +10 -0
- data/lib/rbs/ast/members.rb +2 -0
- data/lib/rbs/ast/type_param.rb +2 -12
- data/lib/rbs/cli/validate.rb +1 -0
- data/lib/rbs/cli.rb +3 -3
- data/lib/rbs/collection/config/lockfile_generator.rb +28 -7
- data/lib/rbs/collection/sources/rubygems.rb +1 -1
- data/lib/rbs/definition.rb +46 -31
- data/lib/rbs/definition_builder/ancestor_builder.rb +2 -0
- data/lib/rbs/definition_builder.rb +86 -30
- data/lib/rbs/environment.rb +33 -18
- data/lib/rbs/errors.rb +24 -0
- data/lib/rbs/locator.rb +2 -0
- data/lib/rbs/method_type.rb +2 -0
- data/lib/rbs/parser_aux.rb +38 -1
- data/lib/rbs/prototype/rb.rb +2 -1
- data/lib/rbs/prototype/rbi.rb +2 -1
- data/lib/rbs/prototype/runtime.rb +3 -0
- data/lib/rbs/subtractor.rb +3 -3
- data/lib/rbs/test/hook.rb +2 -2
- data/lib/rbs/test/type_check.rb +7 -5
- data/lib/rbs/types.rb +45 -10
- data/lib/rbs/unit_test/spy.rb +4 -2
- data/lib/rbs/unit_test/type_assertions.rb +17 -11
- data/lib/rbs/unit_test/with_aliases.rb +3 -1
- data/lib/rbs/validator.rb +4 -0
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +10 -5
- data/lib/rbs.rb +1 -0
- data/rbs.gemspec +1 -1
- data/sig/annotate/rdoc_source.rbs +2 -0
- data/sig/cli.rbs +2 -0
- data/sig/collection/config/lockfile_generator.rbs +1 -1
- data/sig/declarations.rbs +10 -3
- data/sig/definition.rbs +67 -14
- data/sig/definition_builder.rbs +17 -3
- data/sig/directives.rbs +17 -1
- data/sig/environment.rbs +2 -0
- data/sig/errors.rbs +19 -0
- data/sig/namespace.rbs +1 -1
- data/sig/parser.rbs +5 -1
- data/sig/subtractor.rbs +1 -1
- data/sig/test/type_check.rbs +2 -2
- data/sig/type_param.rbs +1 -1
- data/sig/typename.rbs +1 -1
- data/sig/types.rbs +1 -1
- data/sig/unit_test/spy.rbs +2 -0
- data/sig/unit_test/type_assertions.rbs +2 -0
- data/sig/validator.rbs +4 -0
- data/sig/writer.rbs +1 -1
- data/src/ruby_objs.c +12 -6
- data/src/util/rbs_constant_pool.c +342 -0
- data/stdlib/cgi/0/core.rbs +10 -0
- data/stdlib/ipaddr/0/ipaddr.rbs +8 -0
- data/stdlib/json/0/json.rbs +52 -50
- data/stdlib/net-http/0/net-http.rbs +3 -3
- data/stdlib/openssl/0/openssl.rbs +73 -73
- data/stdlib/resolv/0/resolv.rbs +8 -8
- data/stdlib/socket/0/addrinfo.rbs +1 -1
- data/stdlib/socket/0/unix_socket.rbs +4 -2
- data/stdlib/stringio/0/stringio.rbs +1 -1
- data/stdlib/uri/0/common.rbs +17 -0
- metadata +4 -7
- data/templates/include/rbs/constants.h.erb +0 -20
- data/templates/include/rbs/ruby_objs.h.erb +0 -10
- data/templates/src/constants.c.erb +0 -36
- data/templates/src/ruby_objs.c.erb +0 -27
- data/templates/template.rb +0 -122
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 170d86a49dcb384a18b08feffedd7ff3edef07ff08305c566f84f613765af36d
|
4
|
+
data.tar.gz: '09975862bee26d90936c89c7d461c992829665b866053551ff02bd7a679ebd26'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 653e269661b10cce36470bf51163e2ecb056bd9a1714de6c9a6aeb2d3d659b95a73460737b74328fd594cdf6455ee3a90308d63898a447ddc99d8e36b10b9733
|
7
|
+
data.tar.gz: 27fe334fe021669723ad96918d6c01543cfe93b64217229668b7a77182df3c4fde89f4c98bb55577b0b12dc04658bfb735a3813f5d56c0f6b951fe6a8d993edb
|
@@ -14,7 +14,7 @@ jobs:
|
|
14
14
|
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
|
15
15
|
steps:
|
16
16
|
- name: Dependabot metadata
|
17
|
-
uses: dependabot/fetch-metadata@
|
17
|
+
uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7 # v2.3.0
|
18
18
|
id: metadata
|
19
19
|
- name: Checkout repository
|
20
20
|
uses: actions/checkout@v4
|
data/.github/workflows/ruby.yml
CHANGED
@@ -80,3 +80,29 @@ jobs:
|
|
80
80
|
- name: Run test
|
81
81
|
run: |
|
82
82
|
bundle exec rake ${{ matrix.job }}
|
83
|
+
valgrind:
|
84
|
+
runs-on: ubuntu-latest
|
85
|
+
steps:
|
86
|
+
- uses: actions/checkout@v2
|
87
|
+
- uses: ruby/setup-ruby@v1
|
88
|
+
with:
|
89
|
+
ruby-version: "3.4"
|
90
|
+
bundler-cache: none
|
91
|
+
- name: Set working directory as safe
|
92
|
+
run: git config --global --add safe.directory $(pwd)
|
93
|
+
- name: Set up permission
|
94
|
+
run: chmod -R o-w /opt/hostedtoolcache/Ruby
|
95
|
+
- name: Install dependencies
|
96
|
+
run: |
|
97
|
+
sudo apt-get update
|
98
|
+
sudo apt-get install -y libdb-dev curl autoconf automake m4 libtool python3 valgrind
|
99
|
+
- name: Update rubygems & bundler
|
100
|
+
run: |
|
101
|
+
ruby -v
|
102
|
+
gem update --system
|
103
|
+
- name: bin/setup
|
104
|
+
run: |
|
105
|
+
bin/setup
|
106
|
+
- run: bundle exec rake test:valgrind
|
107
|
+
env:
|
108
|
+
RUBY_FREE_AT_EXIT: 1
|
@@ -20,6 +20,8 @@ jobs:
|
|
20
20
|
bundler: none
|
21
21
|
- name: Set working directory as safe
|
22
22
|
run: git config --global --add safe.directory $(pwd)
|
23
|
+
- name: Set up permission
|
24
|
+
run: chmod -R o-w /opt/hostedtoolcache/Ruby
|
23
25
|
- name: Install dependencies
|
24
26
|
run: |
|
25
27
|
sudo apt-get update
|
@@ -20,6 +20,21 @@ jobs:
|
|
20
20
|
uses: ruby/setup-ruby@v1
|
21
21
|
with:
|
22
22
|
ruby-version: ${{ matrix.ruby }}
|
23
|
+
|
24
|
+
# ucrt and mswin have the dev version Ruby.
|
25
|
+
# It introduce checksum mismatches for bundled gems. So remove them before `bundle install`
|
26
|
+
- name: Purge gem caches
|
27
|
+
run: |
|
28
|
+
ruby -e '
|
29
|
+
exit if "${{ matrix.ruby }}" != "ucrt" && "${{ matrix.ruby }}" != "mswin"
|
30
|
+
|
31
|
+
require "open-uri"
|
32
|
+
require "json"
|
33
|
+
|
34
|
+
res = URI.parse("https://stdgems.org/bundled_gems.json").read
|
35
|
+
bundled_gems = JSON.parse(res)["gems"].map{_1["gem"]}
|
36
|
+
system "gem uninstall --force #{bundled_gems.join(" ")}", exception: true
|
37
|
+
'
|
23
38
|
- name: bundle install
|
24
39
|
run: |
|
25
40
|
bundle config set without profilers libs
|
data/.rubocop.yml
CHANGED
@@ -3,7 +3,7 @@ require:
|
|
3
3
|
- rubocop-on-rbs
|
4
4
|
|
5
5
|
AllCops:
|
6
|
-
TargetRubyVersion: 3.
|
6
|
+
TargetRubyVersion: 3.1
|
7
7
|
DisabledByDefault: true
|
8
8
|
Exclude:
|
9
9
|
- 'vendor/bundle/**/*'
|
@@ -44,10 +44,22 @@ RBS/Style:
|
|
44
44
|
Exclude:
|
45
45
|
- 'sig/**/*'
|
46
46
|
- 'test/**/*'
|
47
|
+
RBS/Style/BlockReturnBoolish:
|
48
|
+
Enabled: true
|
49
|
+
RBS/Style/ClassWithSingleton:
|
50
|
+
Enabled: true
|
51
|
+
RBS/Style/DuplicatedType:
|
52
|
+
Enabled: true
|
47
53
|
RBS/Style/EmptyArgument:
|
48
54
|
Enabled: true
|
49
55
|
RBS/Style/InitializeReturnType:
|
50
56
|
Enabled: true
|
57
|
+
RBS/Style/InstanceWithInstance:
|
58
|
+
Enabled: true
|
59
|
+
RBS/Style/OptionalNil:
|
60
|
+
Enabled: true
|
61
|
+
RBS/Style/RedundantParentheses:
|
62
|
+
Enabled: true
|
51
63
|
|
52
64
|
Lint/DuplicateMethods:
|
53
65
|
Enabled: true
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,85 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 3.9.2 (2025-03-31)
|
4
|
+
|
5
|
+
### Library changes
|
6
|
+
|
7
|
+
* Change `{}` to `{ 0 }` ([#2354](https://github.com/ruby/rbs/pull/2354))
|
8
|
+
|
9
|
+
## 3.9.1 (2025-03-24)
|
10
|
+
|
11
|
+
### Miscellaneous
|
12
|
+
|
13
|
+
* `did_you_mean` is a default gem ([#2348](https://github.com/ruby/rbs/pull/2348))
|
14
|
+
* Skip loading ruby_memcheck ([#2347](https://github.com/ruby/rbs/pull/2347))
|
15
|
+
|
16
|
+
## 3.9.0 (2025-03-18)
|
17
|
+
|
18
|
+
### Miscellaneous
|
19
|
+
|
20
|
+
* Update steep ([#2328](https://github.com/ruby/rbs/pull/2328))
|
21
|
+
|
22
|
+
## 3.9.0.pre.2 (2025-03-14)
|
23
|
+
|
24
|
+
### Signature updates
|
25
|
+
|
26
|
+
* `Hash.new` type ([#2323](https://github.com/ruby/rbs/pull/2323))
|
27
|
+
* `Module#define_method` ([#2325](https://github.com/ruby/rbs/pull/2325))
|
28
|
+
* `Object#define_singleton_method` ([#2324](https://github.com/ruby/rbs/pull/2324))
|
29
|
+
|
30
|
+
### Language updates
|
31
|
+
|
32
|
+
* Fix `define_method` method block self type ([#2325](https://github.com/ruby/rbs/pull/2325))
|
33
|
+
|
34
|
+
## 3.9.0.pre.1 (2025-03-11)
|
35
|
+
|
36
|
+
### Signature updates
|
37
|
+
|
38
|
+
* `CGI.escape/unescape_uri_component` ([#2299](https://github.com/ruby/rbs/pull/2299))
|
39
|
+
* `Enumerator::Chain` ([#2220](https://github.com/ruby/rbs/pull/2220))
|
40
|
+
* `IO.read` ([#2216](https://github.com/ruby/rbs/pull/2216))
|
41
|
+
* `IPAddr#netmask` ([#2311](https://github.com/ruby/rbs/pull/2311))
|
42
|
+
* `Kernel#gets`, `Kernel#readline`, `Kernel#readlines` ([#2212](https://github.com/ruby/rbs/pull/2212))
|
43
|
+
* `Net::HTTP.start` ([#2225](https://github.com/ruby/rbs/pull/2225))
|
44
|
+
* `OpenSSL::BN` ([#2267](https://github.com/ruby/rbs/pull/2267))
|
45
|
+
* `OpenSSL::PKey::{RSA,DSA,DH}#params` ([#2255](https://github.com/ruby/rbs/pull/2255))
|
46
|
+
* `UNIXSocket#send_io`, `UNIXSocket#recv_io` ([#2264](https://github.com/ruby/rbs/pull/2264))
|
47
|
+
* `URI.encode/decode_uri_component` ([#2299](https://github.com/ruby/rbs/pull/2299))
|
48
|
+
* Rename to reduce top-level interface and type alias ([#2250](https://github.com/ruby/rbs/pull/2250))
|
49
|
+
|
50
|
+
### Language updates
|
51
|
+
|
52
|
+
* Let class/module alias decls, global decls, and constant decls be annotated ([#2302](https://github.com/ruby/rbs/pull/2302))
|
53
|
+
* Add `resolve-type-names: false` magic comment ([#2234](https://github.com/ruby/rbs/pull/2234))
|
54
|
+
|
55
|
+
### Library changes
|
56
|
+
|
57
|
+
* Remove unused root variable ([#2307](https://github.com/ruby/rbs/pull/2307))
|
58
|
+
* Run Valgrind on CI and fix memory leaks ([#2309](https://github.com/ruby/rbs/pull/2309))
|
59
|
+
* Add information for VariableDuplicationError ([#2310](https://github.com/ruby/rbs/pull/2310))
|
60
|
+
* Reduce Array object allocation during parsing ([#2304](https://github.com/ruby/rbs/pull/2304))
|
61
|
+
* No class variable duplication validation ([#2305](https://github.com/ruby/rbs/pull/2305))
|
62
|
+
* Keep annotations during type name resolution ([#2303](https://github.com/ruby/rbs/pull/2303))
|
63
|
+
* Fix method annotations ([#2301](https://github.com/ruby/rbs/pull/2301))
|
64
|
+
* Fix class variable ([#2300](https://github.com/ruby/rbs/pull/2300))
|
65
|
+
* Add bundled gems to alumnus ([#2288](https://github.com/ruby/rbs/pull/2288))
|
66
|
+
* Exclude `attr_*` methods from duplicate checks. ([#2294](https://github.com/ruby/rbs/pull/2294))
|
67
|
+
* Validate superclass and module-self-type ([#2289](https://github.com/ruby/rbs/pull/2289))
|
68
|
+
* Remove case when `rubygems` and `set` ([#2279](https://github.com/ruby/rbs/pull/2279))
|
69
|
+
* Check variable duplication ([#2241](https://github.com/ruby/rbs/pull/2241))
|
70
|
+
* Validate variable types ([#2237](https://github.com/ruby/rbs/pull/2237))
|
71
|
+
* Remove call to `TypeParam#unchecked!` from C parser ([#2256](https://github.com/ruby/rbs/pull/2256))
|
72
|
+
* Remove call to `Any#todo!` from C parser ([#2249](https://github.com/ruby/rbs/pull/2249))
|
73
|
+
* [rbs/unit_test] Treat nil as a return value ([#2257](https://github.com/ruby/rbs/pull/2257))
|
74
|
+
|
75
|
+
### Miscellaneous
|
76
|
+
|
77
|
+
* Apply rubocop style to RBS ([#2292](https://github.com/ruby/rbs/pull/2292))
|
78
|
+
* Eliminate external HTTP requests on test ([#2253](https://github.com/ruby/rbs/pull/2253))
|
79
|
+
* Prevent a warning: the block passed to 'map_type_name' .. may be ignored ([#2248](https://github.com/ruby/rbs/pull/2248))
|
80
|
+
* Update ruby version for rubocop ([#2251](https://github.com/ruby/rbs/pull/2251))
|
81
|
+
* Drop templates from package ([#2214](https://github.com/ruby/rbs/pull/2214))
|
82
|
+
|
3
83
|
## 3.8.1 (2024-12-27)
|
4
84
|
|
5
85
|
### Signature updates
|
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ bin = File.join(__dir__, "bin")
|
|
11
11
|
|
12
12
|
Rake::ExtensionTask.new("rbs_extension")
|
13
13
|
|
14
|
-
|
14
|
+
test_config = lambda do |t|
|
15
15
|
t.libs << "test"
|
16
16
|
t.libs << "lib"
|
17
17
|
t.test_files = FileList["test/**/*_test.rb"].reject do |path|
|
@@ -19,6 +19,20 @@ Rake::TestTask.new(:test => :compile) do |t|
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
Rake::TestTask.new(test: :compile, &test_config)
|
23
|
+
|
24
|
+
unless Gem.win_platform?
|
25
|
+
begin
|
26
|
+
require "ruby_memcheck"
|
27
|
+
|
28
|
+
namespace :test do
|
29
|
+
RubyMemcheck::TestTask.new(valgrind: :compile, &test_config)
|
30
|
+
end
|
31
|
+
rescue LoadError => exn
|
32
|
+
STDERR.puts "🚨🚨🚨🚨 Skipping RubyMemcheck: #{exn.inspect} 🚨🚨🚨🚨"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
22
36
|
multitask :default => [:test, :stdlib_test, :typecheck_test, :rubocop, :validate, :test_doc]
|
23
37
|
|
24
38
|
task :lexer do
|
@@ -112,7 +126,7 @@ end
|
|
112
126
|
|
113
127
|
task :stdlib_test => :compile do
|
114
128
|
test_files = FileList["test/stdlib/**/*_test.rb"].reject do |path|
|
115
|
-
path =~ %r{Ractor} || path =~ %r{Encoding}
|
129
|
+
path =~ %r{Ractor} || path =~ %r{Encoding} || path =~ %r{CGI_test}
|
116
130
|
end
|
117
131
|
|
118
132
|
if ENV["RANDOMIZE_STDLIB_TEST_ORDER"] == "true"
|
@@ -121,6 +135,7 @@ task :stdlib_test => :compile do
|
|
121
135
|
|
122
136
|
sh "#{ruby} -Ilib #{bin}/test_runner.rb #{test_files.join(' ')}"
|
123
137
|
# TODO: Ractor tests need to be run in a separate process
|
138
|
+
sh "#{ruby} -Ilib #{bin}/test_runner.rb test/stdlib/CGI_test.rb"
|
124
139
|
sh "#{ruby} -Ilib #{bin}/test_runner.rb test/stdlib/Ractor_test.rb"
|
125
140
|
sh "#{ruby} -Ilib #{bin}/test_runner.rb test/stdlib/Encoding_test.rb"
|
126
141
|
end
|
@@ -139,7 +154,9 @@ task :typecheck_test => :compile do
|
|
139
154
|
end
|
140
155
|
|
141
156
|
task :raap => :compile do
|
142
|
-
sh
|
157
|
+
sh "ruby test/raap/core.rb"
|
158
|
+
sh "ruby test/raap/digest.rb"
|
159
|
+
sh "ruby test/raap/openssl.rb"
|
143
160
|
end
|
144
161
|
|
145
162
|
task :rubocop do
|
data/config.yml
CHANGED
@@ -27,18 +27,21 @@ nodes:
|
|
27
27
|
- name: old_name
|
28
28
|
- name: location
|
29
29
|
- name: comment
|
30
|
+
- name: annotations
|
30
31
|
- name: RBS::AST::Declarations::Constant
|
31
32
|
fields:
|
32
33
|
- name: name
|
33
34
|
- name: type
|
34
35
|
- name: location
|
35
36
|
- name: comment
|
37
|
+
- name: annotations
|
36
38
|
- name: RBS::AST::Declarations::Global
|
37
39
|
fields:
|
38
40
|
- name: name
|
39
41
|
- name: type
|
40
42
|
- name: location
|
41
43
|
- name: comment
|
44
|
+
- name: annotations
|
42
45
|
- name: RBS::AST::Declarations::Interface
|
43
46
|
fields:
|
44
47
|
- name: name
|
@@ -67,6 +70,7 @@ nodes:
|
|
67
70
|
- name: old_name
|
68
71
|
- name: location
|
69
72
|
- name: comment
|
73
|
+
- name: annotations
|
70
74
|
- name: RBS::AST::Declarations::TypeAlias
|
71
75
|
fields:
|
72
76
|
- name: name
|
@@ -191,6 +195,7 @@ nodes:
|
|
191
195
|
- name: variance
|
192
196
|
- name: upper_bound
|
193
197
|
- name: default_type
|
198
|
+
- name: unchecked
|
194
199
|
- name: location
|
195
200
|
- name: RBS::MethodType
|
196
201
|
fields:
|
@@ -213,6 +218,7 @@ nodes:
|
|
213
218
|
- name: location
|
214
219
|
- name: RBS::Types::Bases::Any
|
215
220
|
fields:
|
221
|
+
- name: todo
|
216
222
|
- name: location
|
217
223
|
- name: RBS::Types::Bases::Bool
|
218
224
|
fields:
|
data/core/data.rbs
CHANGED
@@ -411,5 +411,5 @@ class Data
|
|
411
411
|
# out = origin.with(z: 1) # ArgumentError: unknown keyword: :z
|
412
412
|
# some_point = origin.with(1, 2) # ArgumentError: expected keyword arguments, got positional arguments
|
413
413
|
#
|
414
|
-
def with: (**untyped) ->
|
414
|
+
def with: (**untyped) -> self
|
415
415
|
end
|
data/core/enumerator.rbs
CHANGED
@@ -613,7 +613,18 @@ end
|
|
613
613
|
# This type of objects can be created by Enumerable#chain and Enumerator#+.
|
614
614
|
#
|
615
615
|
class Enumerator::Chain[out Elem] < Enumerator[Elem, void]
|
616
|
-
|
616
|
+
# <!--
|
617
|
+
# rdoc-file=enumerator.c
|
618
|
+
# - Enumerator::Chain.new(*enums) -> enum
|
619
|
+
# -->
|
620
|
+
# Generates a new enumerator object that iterates over the elements of given
|
621
|
+
# enumerable objects in sequence.
|
622
|
+
#
|
623
|
+
# e = Enumerator::Chain.new(1..3, [4, 5])
|
624
|
+
# e.to_a #=> [1, 2, 3, 4, 5]
|
625
|
+
# e.size #=> 5
|
626
|
+
#
|
627
|
+
def initialize: (*_Each[Elem] enums) -> void
|
617
628
|
|
618
629
|
# <!--
|
619
630
|
# rdoc-file=enumerator.c
|
@@ -626,5 +637,6 @@ class Enumerator::Chain[out Elem] < Enumerator[Elem, void]
|
|
626
637
|
#
|
627
638
|
# If no block is given, returns an enumerator.
|
628
639
|
#
|
629
|
-
def each: () { (Elem) -> void } ->
|
640
|
+
def each: () { (Elem) -> void } -> self
|
641
|
+
| () -> Enumerator[Elem, self]
|
630
642
|
end
|
data/core/exception.rbs
CHANGED
data/core/gc.rbs
CHANGED
data/core/hash.rbs
CHANGED
@@ -1845,8 +1845,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
1845
1845
|
# be resized.
|
1846
1846
|
#
|
1847
1847
|
def initialize: (?capacity: int) -> void
|
1848
|
-
|
|
1849
|
-
|
|
1848
|
+
| (V default, ?capacity: int) -> void
|
1849
|
+
| (?capacity: int) { (Hash[K, V] hash, K key) -> V } -> void
|
1850
1850
|
|
1851
1851
|
# <!--
|
1852
1852
|
# rdoc-file=hash.c
|
data/core/io.rbs
CHANGED
@@ -2278,7 +2278,7 @@ class IO < Object
|
|
2278
2278
|
# potential security vulnerabilities if called with untrusted input; see
|
2279
2279
|
# [Command Injection](rdoc-ref:command_injection.rdoc).
|
2280
2280
|
#
|
2281
|
-
def self.binread: (String name, ?Integer length, ?Integer offset) -> String
|
2281
|
+
def self.binread: (String name, ?Integer? length, ?Integer offset) -> String
|
2282
2282
|
|
2283
2283
|
# <!--
|
2284
2284
|
# rdoc-file=io.c
|
@@ -2343,7 +2343,7 @@ class IO < Object
|
|
2343
2343
|
# IO.copy_stream('t.txt', 't.tmp', 11, 11) # => 11
|
2344
2344
|
# IO.read('t.tmp') # => "Second line"
|
2345
2345
|
#
|
2346
|
-
def self.copy_stream: (String | _Reader | _ReaderPartial src, String | _Writer dst, ?Integer copy_length, ?Integer src_offset) -> Integer
|
2346
|
+
def self.copy_stream: (String | _Reader | _ReaderPartial src, String | _Writer dst, ?Integer? copy_length, ?Integer src_offset) -> Integer
|
2347
2347
|
|
2348
2348
|
# <!--
|
2349
2349
|
# rdoc-file=io.c
|
@@ -2716,7 +2716,7 @@ class IO < Object
|
|
2716
2716
|
# * [Open Options](rdoc-ref:IO@Open+Options).
|
2717
2717
|
# * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
|
2718
2718
|
#
|
2719
|
-
def self.read: (String name, ?Integer length, ?Integer offset, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String) -> String
|
2719
|
+
def self.read: (String name, ?Integer? length, ?Integer offset, ?external_encoding: String | Encoding | nil, ?internal_encoding: String | Encoding | nil, ?encoding: String | Encoding | nil, ?textmode: boolish, ?binmode: boolish, ?autoclose: boolish, ?mode: String) -> String
|
2720
2720
|
|
2721
2721
|
# <!--
|
2722
2722
|
# rdoc-file=io.c
|
@@ -3251,6 +3251,10 @@ class IO < Object
|
|
3251
3251
|
# f.close
|
3252
3252
|
#
|
3253
3253
|
alias to_i fileno
|
3254
|
+
|
3255
|
+
interface _ForFd[RET]
|
3256
|
+
def for_fd: (?) -> RET
|
3257
|
+
end
|
3254
3258
|
end
|
3255
3259
|
|
3256
3260
|
IO::APPEND: Integer
|
data/core/kernel.rbs
CHANGED
@@ -1163,7 +1163,7 @@ module Kernel : BasicObject
|
|
1163
1163
|
# The style of programming using `$_` as an implicit parameter is gradually
|
1164
1164
|
# losing favor in the Ruby community.
|
1165
1165
|
#
|
1166
|
-
def self?.gets: (?String
|
1166
|
+
def self?.gets: (?String sep, ?Integer limit, ?chomp: boolish) -> String?
|
1167
1167
|
|
1168
1168
|
# <!--
|
1169
1169
|
# rdoc-file=eval.c
|
@@ -1486,7 +1486,7 @@ module Kernel : BasicObject
|
|
1486
1486
|
# Optional keyword argument `chomp` specifies whether line separators are to be
|
1487
1487
|
# omitted.
|
1488
1488
|
#
|
1489
|
-
def self?.readline: (?String arg0, ?Integer arg1) -> String
|
1489
|
+
def self?.readline: (?String arg0, ?Integer arg1, ?chomp: boolish) -> String
|
1490
1490
|
|
1491
1491
|
# <!--
|
1492
1492
|
# rdoc-file=io.c
|
@@ -1729,7 +1729,7 @@ module Kernel : BasicObject
|
|
1729
1729
|
def self?.sleep: (?nil) -> bot
|
1730
1730
|
| (Time::_Timeout duration) -> Integer
|
1731
1731
|
|
1732
|
-
%a{
|
1732
|
+
%a{deprecated}
|
1733
1733
|
interface _Divmod
|
1734
1734
|
def divmod: (Numeric) -> [ Numeric, Numeric ]
|
1735
1735
|
end
|
@@ -2297,7 +2297,7 @@ module Kernel : BasicObject
|
|
2297
2297
|
# chris.greet("Hi") #=> "Hi, I'm Chris!"
|
2298
2298
|
#
|
2299
2299
|
def define_singleton_method: (interned name, Method | UnboundMethod | Proc method) -> Symbol
|
2300
|
-
| (interned name) { (?) -> untyped } -> Symbol
|
2300
|
+
| (interned name) { (?) [self: self] -> untyped } -> Symbol
|
2301
2301
|
|
2302
2302
|
# <!--
|
2303
2303
|
# rdoc-file=io.c
|
data/core/method.rbs
CHANGED
@@ -54,7 +54,7 @@ class Method
|
|
54
54
|
#
|
55
55
|
def hash: () -> Integer
|
56
56
|
|
57
|
-
def dup: () ->
|
57
|
+
def dup: () -> self
|
58
58
|
|
59
59
|
# <!--
|
60
60
|
# rdoc-file=proc.c
|
@@ -252,7 +252,7 @@ class Method
|
|
252
252
|
# m.call # => "bar"
|
253
253
|
# n = m.clone.call # => "bar"
|
254
254
|
#
|
255
|
-
def clone: () ->
|
255
|
+
def clone: () -> self
|
256
256
|
|
257
257
|
# <!--
|
258
258
|
# rdoc-file=proc.c
|
data/core/module.rbs
CHANGED
@@ -731,8 +731,8 @@ class Module < Object
|
|
731
731
|
# I'm Dino!
|
732
732
|
# #<B:0x401b39e8>
|
733
733
|
#
|
734
|
-
def define_method: (interned symbol, ^() [self:
|
735
|
-
| (interned symbol) { () [self:
|
734
|
+
def define_method: (interned symbol, ^(?) [self: top] -> untyped | Method | UnboundMethod method) -> Symbol
|
735
|
+
| (interned symbol) { (?) [self: top] -> untyped } -> Symbol
|
736
736
|
|
737
737
|
# <!--
|
738
738
|
# rdoc-file=object.c
|
@@ -1164,7 +1164,7 @@ class Module < Object
|
|
1164
1164
|
# -->
|
1165
1165
|
# Returns the name of the module *mod*. Returns `nil` for anonymous modules.
|
1166
1166
|
#
|
1167
|
-
def name: () -> String
|
1167
|
+
def name: %a{implicitly-returns-nil} () -> String
|
1168
1168
|
|
1169
1169
|
# <!--
|
1170
1170
|
# rdoc-file=eval.c
|
@@ -1699,6 +1699,6 @@ class Module < Object
|
|
1699
1699
|
def attr: (*interned arg0) -> Array[Symbol]
|
1700
1700
|
|
1701
1701
|
# A previous incarnation of `interned` for backward-compatibility (see #1499)
|
1702
|
-
%a{
|
1702
|
+
%a{deprecated: Use `interned`}
|
1703
1703
|
type id = interned
|
1704
1704
|
end
|
data/core/object.rbs
CHANGED
data/core/proc.rbs
CHANGED
@@ -376,8 +376,8 @@ class Proc
|
|
376
376
|
#
|
377
377
|
def self.new: () { (?) -> untyped } -> instance
|
378
378
|
|
379
|
-
def clone: () ->
|
380
|
-
def dup: () ->
|
379
|
+
def clone: () -> self
|
380
|
+
def dup: () -> self
|
381
381
|
|
382
382
|
# <!-- rdoc-file=proc.c -->
|
383
383
|
# Invokes the block, setting the block's parameters to the values in *params*
|
data/core/rbs/unnamed/argf.rbs
CHANGED
@@ -639,7 +639,7 @@ module RBS
|
|
639
639
|
# See IO.readlines for details about getline_args.
|
640
640
|
#
|
641
641
|
%a{annotate:rdoc:copy:ARGF#gets}
|
642
|
-
def gets: (?String sep, ?Integer limit) -> String?
|
642
|
+
def gets: (?String sep, ?Integer limit, ?chomp: boolish) -> String?
|
643
643
|
|
644
644
|
# <!--
|
645
645
|
# rdoc-file=io.c
|
@@ -1024,7 +1024,7 @@ module RBS
|
|
1024
1024
|
# An EOFError is raised at the end of the file.
|
1025
1025
|
#
|
1026
1026
|
%a{annotate:rdoc:copy:ARGF#readline}
|
1027
|
-
def readline: (?String sep, ?Integer limit) -> String
|
1027
|
+
def readline: (?String sep, ?Integer limit, ?chomp: boolish) -> String
|
1028
1028
|
|
1029
1029
|
# <!--
|
1030
1030
|
# rdoc-file=io.c
|
@@ -1044,7 +1044,7 @@ module RBS
|
|
1044
1044
|
# See `IO.readlines` for a full description of all options.
|
1045
1045
|
#
|
1046
1046
|
%a{annotate:rdoc:copy:ARGF#readlines}
|
1047
|
-
def readlines: (?String sep, ?Integer limit) -> ::Array[String]
|
1047
|
+
def readlines: (?String sep, ?Integer limit, ?chomp: boolish) -> ::Array[String]
|
1048
1048
|
|
1049
1049
|
# <!--
|
1050
1050
|
# rdoc-file=io.c
|
data/core/rubygems/version.rbs
CHANGED
@@ -221,7 +221,7 @@ module Gem
|
|
221
221
|
#
|
222
222
|
# Pre-release (alpha) parts, e.g, 5.3.1.b.2 => 5.4, are ignored.
|
223
223
|
#
|
224
|
-
def bump: () ->
|
224
|
+
def bump: () -> self
|
225
225
|
|
226
226
|
# <!--
|
227
227
|
# rdoc-file=lib/rubygems/version.rb
|
@@ -274,7 +274,7 @@ module Gem
|
|
274
274
|
# The release for this version (e.g. 1.2.0.a -> 1.2.0). Non-prerelease versions
|
275
275
|
# return themselves.
|
276
276
|
#
|
277
|
-
def release: () ->
|
277
|
+
def release: () -> self
|
278
278
|
|
279
279
|
# <!--
|
280
280
|
# rdoc-file=lib/rubygems/version.rb
|
data/core/string.rbs
CHANGED
@@ -1936,7 +1936,7 @@ class String
|
|
1936
1936
|
?crlf_newline: boolish,
|
1937
1937
|
?lf_newline: boolish,
|
1938
1938
|
?fallback: ^(String) -> string? | Method | _EncodeFallbackAref
|
1939
|
-
) ->
|
1939
|
+
) -> self
|
1940
1940
|
|
1941
1941
|
interface _EncodeFallbackAref
|
1942
1942
|
def []: (String) -> string?
|
@@ -3574,10 +3574,10 @@ class String
|
|
3574
3574
|
def valid_encoding?: () -> bool
|
3575
3575
|
end
|
3576
3576
|
|
3577
|
-
%a{
|
3577
|
+
%a{deprecated}
|
3578
3578
|
interface _ArefFromStringToString
|
3579
3579
|
def []: (String) -> String
|
3580
3580
|
end
|
3581
3581
|
|
3582
|
-
%a{
|
3582
|
+
%a{deprecated}
|
3583
3583
|
type String::encode_fallback = Hash[String, String] | Proc | Method | _ArefFromStringToString
|
data/core/unbound_method.rbs
CHANGED
data/docs/syntax.md
CHANGED
@@ -289,7 +289,9 @@ The following `class`/`instance` types are allowed.
|
|
289
289
|
class Foo
|
290
290
|
attr_reader parent: class
|
291
291
|
|
292
|
-
def foo: () -> instance
|
292
|
+
def foo: () -> instance # behaves like `self` in this context
|
293
|
+
|
294
|
+
def self?.bar: () -> instance # behaves like `class` for `def self.bar()` and `self` for `def bar()`
|
293
295
|
|
294
296
|
@@foos: Array[instance]
|
295
297
|
|
@@ -405,9 +407,12 @@ _ivar-member_ ::= _ivar-name_ `:` _type_
|
|
405
407
|
| `self` `.` _ivar-name_ `:` _type_
|
406
408
|
| _cvar-name_ `:` _type_
|
407
409
|
|
408
|
-
_method-member_ ::=
|
409
|
-
|
|
410
|
-
|
410
|
+
_method-member_ ::= _method-class-member_
|
411
|
+
| _method-interface-member_
|
412
|
+
_method-class-member_ ::= _visibility_ `def` _method-name_ `:` _method-types_ # Instance method
|
413
|
+
| _visibility_ `def self.` _method-name_ `:` _method-types_ # Singleton method
|
414
|
+
| `def self?.` _method-name_ `:` _method-types_ # Singleton and instance method
|
415
|
+
_method-interface-member_ ::= `def` _method-name_ `:` _method-types_ # Instance method
|
411
416
|
|
412
417
|
_method-types_ ::= _method-type-parameters_ _method-type_ # Single method type
|
413
418
|
| _method-type-parameters_ _method-type_ `|` _method-types_ # Overloading types
|
@@ -624,7 +629,7 @@ _module-self-types_ ::= _class-name_ _type-arguments_ `,` _module-self-types_
|
|
624
629
|
|
625
630
|
_interface-decl_ ::= `interface` _interface-name_ _module-type-parameters_ _interface-members_ `end`
|
626
631
|
|
627
|
-
_interface-members_ ::= _method-member_
|
632
|
+
_interface-members_ ::= _method-interface-member_ # Method
|
628
633
|
| _include-interface-member_ # Mixin (include)
|
629
634
|
| _alias-member_ # Alias
|
630
635
|
|
@@ -4,10 +4,11 @@ $INCFLAGS << " -I$(top_srcdir)" if $extmk
|
|
4
4
|
$INCFLAGS << " -I$(srcdir)/../../include"
|
5
5
|
|
6
6
|
$VPATH << "$(srcdir)/../../src"
|
7
|
+
$VPATH << "$(srcdir)/../../src/util"
|
7
8
|
$VPATH << "$(srcdir)/ext/rbs_extension"
|
8
9
|
|
9
10
|
root_dir = File.expand_path('../../../', __FILE__)
|
10
|
-
$srcs = Dir.glob("#{root_dir}/src
|
11
|
+
$srcs = Dir.glob("#{root_dir}/src/**/*.c") +
|
11
12
|
Dir.glob("#{root_dir}/ext/rbs_extension/*.c")
|
12
13
|
|
13
14
|
append_cflags ['-std=gnu99']
|