rbs 4.2.0.pre.1 → 4.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d5559ae50bcf0c82ad2410de2a377281851fd0156e31d305ac42bfcd6c68867
4
- data.tar.gz: 5e8fd44b4f83cae246ebe0683ecf46a933986bf882a9d14857cc0c0cac2c848a
3
+ metadata.gz: 3e76f94a794b829effcba20a9dc637da54915d4bb3a87fa1b4200c4091fa60a6
4
+ data.tar.gz: 5f6eb47e5f31023f56ccede03402493f223719fa5dc1033995fecc592e87e2f1
5
5
  SHA512:
6
- metadata.gz: 6a8ee224d637ca355d061d971061c6754165add8dec1e8b0cfd6083fdd030e9b1ff5dbf7bdb35bfc103c9f1cba24b5233a029e102d6996fe1edc0c4bcf49ce54
7
- data.tar.gz: 2620421db463ab2150517408e6ba6e826ea6408847be33cd2c5b685198b571acddf66abccddd023ac5dcd60dc08b0d8c8936a01760f1979dc9218ac0731ff8db
6
+ metadata.gz: 168b150476b5515f06f4bc72a58854bc2c60cf073365761ceacf9dc48a5be22d41a0469c168e76ac9d85d03fbdb0e67ac2f7d3564ee6055191432514ff56b10c
7
+ data.tar.gz: 80e89dae7445279f1ee30c825280af61259363911fc78032812dfd1be5f4fc7677598732ca42b3366dff2bc1269fe8b7cd8e6bfa49ccd8a225fe318285bfdfb1
data/.rubocop.yml CHANGED
@@ -3,7 +3,6 @@ plugins:
3
3
  - rubocop-on-rbs
4
4
 
5
5
  AllCops:
6
- TargetRubyVersion: 3.4
7
6
  DisabledByDefault: true
8
7
  Exclude:
9
8
  - 'vendor/bundle/**/*'
data/CHANGELOG.md CHANGED
@@ -1,6 +1,27 @@
1
1
  # CHANGELOG
2
2
 
3
- ## 4.2.0.pre.1 (2026-08-18)
3
+ ## 4.2.0 (2026-08-23)
4
+
5
+ RBS 4.2 accepts non-ASCII characters in identifiers. Method names, instance variable names and parameter names can be written in any script, and other names may contain non-ASCII characters as long as they start with an ASCII letter, which is what tells a constant from a method name.
6
+
7
+ ```rbs
8
+ class Greeter
9
+ @挨拶: String
10
+
11
+ def こんにちは: () -> String
12
+ end
13
+ ```
14
+
15
+ The parser and the AST support Ruby-style `...` forwarding parameters in method types, but the layers built on top of the parser do not yet. The syntax is disabled by default in 4.2 and is not enabled by the public `RBS::Parser` API, so it cannot be used in regular RBS signatures yet.
16
+
17
+ Ruby 3.2 reached EOL on 2026-04-01, and this release requires Ruby 3.3 or later. Applications on 3.2 stay on the 4.1 line.
18
+
19
+ ### Signature updates
20
+
21
+ **Updated classes/modules/methods:** `ERB`, `ERB::DefMethod`, `IO`, `Monitor`, `MonitorMixin::ConditionVariable`, `Singleton`, `StringIO`, `Zlib::GzipFile`, `Zlib::GzipWriter`
22
+
23
+ * Replace deterministic `untyped` return types with concrete types ([#2966](https://github.com/ruby/rbs/pull/2966))
24
+ * Declare Singleton::SingletonInstanceMethods ([#3037](https://github.com/ruby/rbs/pull/3037))
4
25
 
5
26
  ### Language updates
6
27
 
@@ -10,6 +31,7 @@
10
31
 
11
32
  ### Library changes
12
33
 
34
+ * Drop runtime support for Ruby 3.2 ([#3095](https://github.com/ruby/rbs/pull/3095))
13
35
  * Stop the lexer reading past the end of a byte_range ([#3040](https://github.com/ruby/rbs/pull/3040))
14
36
  * Exclude CR from comment tokens to fix an off-by-one Location#end_line on CRLF files ([#3069](https://github.com/ruby/rbs/pull/3069))
15
37
  * Handle the NULL parser in the WebAssembly shim ([#3085](https://github.com/ruby/rbs/pull/3085))
@@ -24,6 +46,7 @@
24
46
 
25
47
  ### Miscellaneous
26
48
 
49
+ * Omit forwarding parameter tests on JRuby ([#3092](https://github.com/ruby/rbs/pull/3092))
27
50
  * Skip JSON 2-only tests with JSON 3 ([#3084](https://github.com/ruby/rbs/pull/3084))
28
51
  * Pin GitHub Actions to commit hashes ([#3020](https://github.com/ruby/rbs/pull/3020))
29
52
 
data/core/io.rbs CHANGED
@@ -1417,7 +1417,8 @@ class IO < Object
1417
1417
  #
1418
1418
  # AA
1419
1419
  #
1420
- def putc: (Numeric | String object) -> (Numeric | String)
1420
+ def putc: (real) -> real
1421
+ | (String) -> String
1421
1422
 
1422
1423
  # <!--
1423
1424
  # rdoc-file=io.c
@@ -5,58 +5,25 @@ module RBS
5
5
  module Helpers
6
6
  private
7
7
 
8
- # Prism can't parse Ruby 3.2 code
9
- if RUBY_VERSION >= "3.3"
10
- def parse_comments(string, include_trailing:)
11
- Prism.parse_comments(string, version: "current").yield_self do |prism_comments| # steep:ignore UnexpectedKeywordArgument
12
- prism_comments.each_with_object({}) do |comment, hash| #$ Hash[Integer, AST::Comment]
13
- # Skip EmbDoc comments
14
- next unless comment.is_a?(Prism::InlineComment)
15
- # skip like `module Foo # :nodoc:`
16
- next if comment.trailing? && !include_trailing
17
-
18
- line = comment.location.start_line
19
- body = "#{comment.location.slice}\n"
20
- body = body[2..-1] or raise
21
- body = "\n" if body.empty?
22
-
23
- comment = AST::Comment.new(string: body, location: nil)
24
- if prev_comment = hash.delete(line - 1)
25
- hash[line] = AST::Comment.new(string: prev_comment.string + comment.string,
26
- location: nil)
27
- else
28
- hash[line] = comment
29
- end
30
- end
31
- end
32
- end
33
- else
34
- require "ripper"
35
- def parse_comments(string, include_trailing:)
36
- Ripper.lex(string).yield_self do |tokens|
37
- code_lines = {} #: Hash[Integer, bool]
38
- tokens.each.with_object({}) do |token, hash| #$ Hash[Integer, AST::Comment]
39
- case token[1]
40
- when :on_sp, :on_ignored_nl
41
- # skip
42
- when :on_comment
43
- line = token[0][0]
44
- # skip like `module Foo # :nodoc:`
45
- next if code_lines[line] && !include_trailing
46
- body = token[2][2..-1] or raise
47
-
48
- body = "\n" if body.empty?
49
-
50
- comment = AST::Comment.new(string: body, location: nil)
51
- if prev_comment = hash.delete(line - 1)
52
- hash[line] = AST::Comment.new(string: prev_comment.string + comment.string,
53
- location: nil)
54
- else
55
- hash[line] = comment
56
- end
57
- else
58
- code_lines[token[0][0]] = true
59
- end
8
+ def parse_comments(string, include_trailing:)
9
+ Prism.parse_comments(string, version: "current").yield_self do |prism_comments| # steep:ignore UnexpectedKeywordArgument
10
+ prism_comments.each_with_object({}) do |comment, hash| #$ Hash[Integer, AST::Comment]
11
+ # Skip EmbDoc comments
12
+ next unless comment.is_a?(Prism::InlineComment)
13
+ # skip like `module Foo # :nodoc:`
14
+ next if comment.trailing? && !include_trailing
15
+
16
+ line = comment.location.start_line
17
+ body = "#{comment.location.slice}\n"
18
+ body = body[2..-1] or raise
19
+ body = "\n" if body.empty?
20
+
21
+ comment = AST::Comment.new(string: body, location: nil)
22
+ if prev_comment = hash.delete(line - 1)
23
+ hash[line] = AST::Comment.new(string: prev_comment.string + comment.string,
24
+ location: nil)
25
+ else
26
+ hash[line] = comment
60
27
  end
61
28
  end
62
29
  end
@@ -212,7 +212,6 @@ module RBS
212
212
 
213
213
  class DataGenerator < ValueObjectBase
214
214
  def self.generatable?(target)
215
- return false unless RUBY_VERSION >= '3.2'
216
215
  return false unless target < Data
217
216
  # Avoid direct inherited class like `class Option < Data`
218
217
  return false unless target.respond_to?(:members)
@@ -527,7 +527,7 @@ module RBS
527
527
 
528
528
  generate_mixin(mod, decl, type_name, type_name_absolute)
529
529
 
530
- unless mod < Struct || (RUBY_VERSION >= '3.2' && mod < Data)
530
+ unless mod < Struct || mod < Data
531
531
  generate_methods(mod, type_name, decl.members) unless outline
532
532
  end
533
533
 
data/lib/rbs/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RBS
4
- VERSION = "4.2.0.pre.1"
4
+ VERSION = "4.2.0"
5
5
  end
data/rbs.gemspec CHANGED
@@ -67,14 +67,10 @@ Gem::Specification.new do |spec|
67
67
  spec.extensions = %w{ext/rbs_extension/extconf.rb}
68
68
  end
69
69
 
70
- if false
71
- spec.required_ruby_version = ">= 3.4"
72
- end
73
-
74
70
  spec.bindir = "exe"
75
71
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
76
72
  spec.require_paths = ["lib"]
77
- spec.required_ruby_version = ">= 3.2"
73
+ spec.required_ruby_version = ">= 3.3"
78
74
  spec.add_dependency "logger"
79
75
  spec.add_dependency "prism", ">= 1.6.0"
80
76
  spec.add_dependency "tsort"
data/stdlib/erb/0/erb.rbs CHANGED
@@ -619,7 +619,7 @@ class ERB
619
619
  # It's good practice to choose a variable name that begins with an underscore:
620
620
  # <code>'_'</code>.
621
621
  #
622
- def initialize: (String, ?eoutvar: String, ?trim_mode: Integer | String | NilClass) -> untyped
622
+ def initialize: (String, ?eoutvar: String, ?trim_mode: Integer | String | NilClass) -> void
623
623
 
624
624
  # <!-- rdoc-file=lib/erb.rb -->
625
625
  # Returns the Ruby code that, when executed, generates the result;
@@ -702,7 +702,7 @@ class ERB
702
702
  # Like #result, but prints the result string (instead of returning it);
703
703
  # returns `nil`.
704
704
  #
705
- def run: (?Binding) -> untyped
705
+ def run: (?Binding) -> nil
706
706
 
707
707
  # <!--
708
708
  # rdoc-file=lib/erb.rb
@@ -746,7 +746,7 @@ class ERB
746
746
  # class MyClass; include MyModule; end
747
747
  # MyClass.new.render('foo', 123) # => "foo 123"
748
748
  #
749
- def def_method: (Module, String, ?String) -> untyped
749
+ def def_method: (Module, String, ?String) -> Symbol
750
750
 
751
751
  # <!--
752
752
  # rdoc-file=lib/erb.rb
@@ -913,7 +913,7 @@ class ERB
913
913
  # define *methodname* as instance method of current module, using ERB object or
914
914
  # eRuby file
915
915
  #
916
- def self.def_erb_method: (String methodname, (String | ERB) erb_or_fname) -> untyped
916
+ def self.def_erb_method: (String methodname, (String | ERB) erb_or_fname) -> Symbol
917
917
  end
918
918
 
919
919
  # <!-- rdoc-file=lib/erb/util.rb -->
@@ -111,7 +111,7 @@ class Monitor
111
111
  # - wait_for_cond(p1, p2)
112
112
  # -->
113
113
  #
114
- def wait_for_cond: (::MonitorMixin::ConditionVariable, Numeric? timeout) -> untyped
114
+ def wait_for_cond: (::MonitorMixin::ConditionVariable, Numeric? timeout) -> bool
115
115
  end
116
116
 
117
117
  # <!-- rdoc-file=ext/monitor/lib/monitor.rb -->
@@ -334,7 +334,7 @@ class MonitorMixin::ConditionVariable
334
334
  # If `timeout` is given, this method returns after `timeout` seconds passed,
335
335
  # even if no other thread doesn't signal.
336
336
  #
337
- def wait: (?Numeric? timeout) -> untyped
337
+ def wait: (?Numeric? timeout) -> bool
338
338
 
339
339
  # <!--
340
340
  # rdoc-file=ext/monitor/lib/monitor.rb
@@ -342,7 +342,7 @@ class MonitorMixin::ConditionVariable
342
342
  # -->
343
343
  # Calls wait repeatedly until the given block yields a truthy value.
344
344
  #
345
- def wait_until: () { () -> boolish } -> untyped
345
+ def wait_until: () { () -> boolish } -> nil
346
346
 
347
347
  # <!--
348
348
  # rdoc-file=ext/monitor/lib/monitor.rb
@@ -350,7 +350,7 @@ class MonitorMixin::ConditionVariable
350
350
  # -->
351
351
  # Calls wait repeatedly while the given block yields a truthy value.
352
352
  #
353
- def wait_while: () { () -> boolish } -> untyped
353
+ def wait_while: () { () -> boolish } -> nil
354
354
 
355
355
  private
356
356
 
@@ -124,6 +124,9 @@ module Singleton
124
124
  #
125
125
  def dup: () -> bot
126
126
 
127
+ module SingletonInstanceMethods
128
+ end
129
+
127
130
  module SingletonClassMethods
128
131
  end
129
132
  end
@@ -1272,7 +1272,8 @@ class StringIO
1272
1272
  # -->
1273
1273
  # See IO#putc.
1274
1274
  #
1275
- def putc: (Numeric | String arg0) -> untyped
1275
+ def putc: (real) -> real
1276
+ | (String) -> String
1276
1277
 
1277
1278
  def puts: (*untyped arg0) -> nil
1278
1279
 
@@ -143,7 +143,7 @@ module Zlib
143
143
  # `flush` method. While `sync` mode is `true`, the compression ratio decreases
144
144
  # sharply.
145
145
  #
146
- def sync=: (boolish) -> untyped
146
+ def sync=: (boolish) -> boolish
147
147
 
148
148
  # <!--
149
149
  # rdoc-file=ext/zlib/zlib.c
@@ -125,7 +125,8 @@ module Zlib
125
125
  # -->
126
126
  # Same as IO.
127
127
  #
128
- def putc: (Numeric | String arg0) -> untyped
128
+ def putc: (real) -> real
129
+ | (String) -> String
129
130
 
130
131
  # <!--
131
132
  # rdoc-file=ext/zlib/zlib.c
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0.pre.1
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
@@ -644,14 +644,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
644
644
  requirements:
645
645
  - - ">="
646
646
  - !ruby/object:Gem::Version
647
- version: '3.2'
647
+ version: '3.3'
648
648
  required_rubygems_version: !ruby/object:Gem::Requirement
649
649
  requirements:
650
650
  - - ">="
651
651
  - !ruby/object:Gem::Version
652
652
  version: '0'
653
653
  requirements: []
654
- rubygems_version: 4.0.18
654
+ rubygems_version: 4.0.19
655
655
  specification_version: 4
656
656
  summary: Type signature for Ruby.
657
657
  test_files: []