Skip to content

Commit f24fb1f

Browse files
authored
Merge branch 'master' into claude/collection-init-agent-friendly
2 parents 2bd3d70 + 8aee3b6 commit f24fb1f

16 files changed

Lines changed: 71 additions & 75 deletions

File tree

.rubocop.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ plugins:
33
- rubocop-on-rbs
44

55
AllCops:
6-
TargetRubyVersion: 3.4
76
DisabledByDefault: true
87
Exclude:
98
- 'vendor/bundle/**/*'

CHANGELOG.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
# CHANGELOG
22

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))
425

526
### Language updates
627

@@ -10,6 +31,7 @@
1031

1132
### Library changes
1233

34+
* Drop runtime support for Ruby 3.2 ([#3095](https://github.com/ruby/rbs/pull/3095))
1335
* Stop the lexer reading past the end of a byte_range ([#3040](https://github.com/ruby/rbs/pull/3040))
1436
* 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))
1537
* Handle the NULL parser in the WebAssembly shim ([#3085](https://github.com/ruby/rbs/pull/3085))
@@ -24,6 +46,7 @@
2446

2547
### Miscellaneous
2648

49+
* Omit forwarding parameter tests on JRuby ([#3092](https://github.com/ruby/rbs/pull/3092))
2750
* Skip JSON 2-only tests with JSON 3 ([#3084](https://github.com/ruby/rbs/pull/3084))
2851
* Pin GitHub Actions to commit hashes ([#3020](https://github.com/ruby/rbs/pull/3020))
2952

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ GIT
2222
PATH
2323
remote: .
2424
specs:
25-
rbs (4.2.0.pre.1)
25+
rbs (4.2.0)
2626
logger
2727
prism (>= 1.6.0)
2828
tsort

core/io.rbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,8 @@ class IO < Object
14171417
#
14181418
# AA
14191419
#
1420-
def putc: (Numeric | String object) -> (Numeric | String)
1420+
def putc: (real) -> real
1421+
| (String) -> String
14211422

14221423
# <!--
14231424
# rdoc-file=io.c

lib/rbs/prototype/helpers.rb

Lines changed: 19 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,58 +5,25 @@ module Prototype
55
module Helpers
66
private
77

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
6027
end
6128
end
6229
end

lib/rbs/prototype/runtime.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ def generate_class(mod)
527527

528528
generate_mixin(mod, decl, type_name, type_name_absolute)
529529

530-
unless mod < Struct || (RUBY_VERSION >= '3.2' && mod < Data)
530+
unless mod < Struct || mod < Data
531531
generate_methods(mod, type_name, decl.members) unless outline
532532
end
533533

lib/rbs/prototype/runtime/value_object_generator.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ def build_s_keyword_init_p
212212

213213
class DataGenerator < ValueObjectBase
214214
def self.generatable?(target)
215-
return false unless RUBY_VERSION >= '3.2'
216215
return false unless target < Data
217216
# Avoid direct inherited class like `class Option < Data`
218217
return false unless target.respond_to?(:members)

lib/rbs/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module RBS
4-
VERSION = "4.2.0.pre.1"
4+
VERSION = "4.2.0"
55
end

rbs.gemspec

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,10 @@ Gem::Specification.new do |spec|
6767
spec.extensions = %w{ext/rbs_extension/extconf.rb}
6868
end
6969

70-
if false
71-
spec.required_ruby_version = ">= 3.4"
72-
end
73-
7470
spec.bindir = "exe"
7571
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
7672
spec.require_paths = ["lib"]
77-
spec.required_ruby_version = ">= 3.2"
73+
spec.required_ruby_version = ">= 3.3"
7874
spec.add_dependency "logger"
7975
spec.add_dependency "prism", ">= 1.6.0"
8076
spec.add_dependency "tsort"

stdlib/erb/0/erb.rbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ class ERB
619619
# It's good practice to choose a variable name that begins with an underscore:
620620
# <code>'_'</code>.
621621
#
622-
def initialize: (String, ?eoutvar: String, ?trim_mode: Integer | String | NilClass) -> untyped
622+
def initialize: (String, ?eoutvar: String, ?trim_mode: Integer | String | NilClass) -> void
623623

624624
# <!-- rdoc-file=lib/erb.rb -->
625625
# Returns the Ruby code that, when executed, generates the result;
@@ -702,7 +702,7 @@ class ERB
702702
# Like #result, but prints the result string (instead of returning it);
703703
# returns `nil`.
704704
#
705-
def run: (?Binding) -> untyped
705+
def run: (?Binding) -> nil
706706

707707
# <!--
708708
# rdoc-file=lib/erb.rb
@@ -746,7 +746,7 @@ class ERB
746746
# class MyClass; include MyModule; end
747747
# MyClass.new.render('foo', 123) # => "foo 123"
748748
#
749-
def def_method: (Module, String, ?String) -> untyped
749+
def def_method: (Module, String, ?String) -> Symbol
750750

751751
# <!--
752752
# rdoc-file=lib/erb.rb
@@ -913,7 +913,7 @@ class ERB
913913
# define *methodname* as instance method of current module, using ERB object or
914914
# eRuby file
915915
#
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
917917
end
918918

919919
# <!-- rdoc-file=lib/erb/util.rb -->

0 commit comments

Comments
 (0)