Skip to content

Commit e721ad1

Browse files
committed
Drop runtime support for Ruby 3.2
Ruby 3.2 reached EOL on 2026-04-01, and CI has been running 3.3, 3.4, 4.0 and head for a while, so 3.2 is declared as supported without being tested. Raise `required_ruby_version` to `>= 3.3` and delete the code that only existed for 3.2: - `Prototype::Helpers#parse_comments` had a Ripper implementation for 3.2, where Prism cannot parse the source. Only the Prism one is left. - The `RUBY_VERSION >= '3.2'` guards around `Data` in the runtime prototype are always true now. `.rubocop.yml` pinned `TargetRubyVersion` to 3.4 while the gem accepted 3.2. Drop the setting rather than correct it: with nothing pinned, RuboCop reads `required_ruby_version` from the gemspec, so the two cannot drift apart again. The tree is clean at the inferred 3.3. The `if false` block that set `required_ruby_version` to `>= 3.4` is dead code from an earlier experiment and goes with it. Closes #2830 Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 584b4cf commit e721ad1

5 files changed

Lines changed: 21 additions & 60 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/**/*'

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)

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"

0 commit comments

Comments
 (0)