From fc3a5d0f2c0a3130dfffafadb7cd6c6d35d9c5ce Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Wed, 18 Mar 2026 15:57:49 +0100 Subject: [PATCH] Bump required ruby version to 3.2 3.1 and earlier are EOL today. I want to write new syntax and use new methods without having to worry about the consequences. A major version is a nice oportunity to do this. 2.7 to 3.2 is a bit of a jump but there are very few changes to prism that actually require any changes from consumers. --- .github/dependabot.yml | 3 -- .github/workflows/main.yml | 13 +----- README.md | 2 +- bin/prism | 1 - docs/releasing.md | 2 +- gemfiles/2.7/Gemfile | 14 ------- gemfiles/2.7/Gemfile.lock | 42 ------------------- gemfiles/3.0/Gemfile | 14 ------- gemfiles/3.0/Gemfile.lock | 42 ------------------- gemfiles/3.1/Gemfile | 14 ------- gemfiles/3.1/Gemfile.lock | 42 ------------------- lib/prism.rb | 2 - lib/prism/polyfill/byteindex.rb | 13 ------ lib/prism/polyfill/unpack1.rb | 14 ------- lib/prism/polyfill/warn.rb | 36 ---------------- prism.gemspec | 5 +-- rakelib/test.rake | 3 -- templates/lib/prism/serialize.rb.erb | 1 - .../regular_expression_encoding_test.rb | 1 - test/prism/fixtures_test.rb | 2 - test/prism/lex_test.rb | 2 - test/prism/result/warnings_test.rb | 2 - test/prism/ruby/parameters_signature_test.rb | 2 - test/prism/unescape_test.rb | 1 - 24 files changed, 5 insertions(+), 268 deletions(-) delete mode 100644 gemfiles/2.7/Gemfile delete mode 100644 gemfiles/2.7/Gemfile.lock delete mode 100644 gemfiles/3.0/Gemfile delete mode 100644 gemfiles/3.0/Gemfile.lock delete mode 100644 gemfiles/3.1/Gemfile delete mode 100644 gemfiles/3.1/Gemfile.lock delete mode 100644 lib/prism/polyfill/byteindex.rb delete mode 100644 lib/prism/polyfill/unpack1.rb delete mode 100644 lib/prism/polyfill/warn.rb diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6e302f18de..a388f21314 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -18,9 +18,6 @@ updates: - "*" - package-ecosystem: 'bundler' directories: - - '/gemfiles/2.7' - - '/gemfiles/3.0' - - '/gemfiles/3.1' - '/gemfiles/3.2' - '/gemfiles/3.3' - '/gemfiles/3.4' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 356956ec8f..8c993a4dc4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,13 +27,13 @@ jobs: template: runs-on: ubuntu-latest env: - BUNDLE_GEMFILE: gemfiles/2.7/Gemfile + BUNDLE_GEMFILE: gemfiles/3.2/Gemfile steps: - uses: actions/checkout@v6 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: "2.7.0" + ruby-version: "3.2.0" bundler-cache: true - name: Generate templates run: bundle exec rake templates @@ -270,9 +270,6 @@ jobs: fail-fast: false matrix: target: - - { ruby: "2.7", os: "ubuntu-latest", gemfile: "2.7" } - - { ruby: "3.0", os: "ubuntu-latest", gemfile: "3.0" } - - { ruby: "3.1", os: "ubuntu-latest", gemfile: "3.1" } - { ruby: "3.2", os: "ubuntu-latest", gemfile: "3.2" } - { ruby: "3.3", os: "ubuntu-latest", gemfile: "3.3" } - { ruby: "3.4", os: "ubuntu-latest", gemfile: "3.4" } @@ -281,9 +278,6 @@ jobs: - { ruby: "jruby", os: "ubuntu-latest", gemfile: ".." } - { ruby: "truffleruby", os: "ubuntu-latest", gemfile: ".." } - - { ruby: "2.7", os: "macos-latest", gemfile: "2.7" } - - { ruby: "3.0", os: "macos-latest", gemfile: "3.0" } - - { ruby: "3.1", os: "macos-latest", gemfile: "3.1" } - { ruby: "3.2", os: "macos-latest", gemfile: "3.2" } - { ruby: "3.3", os: "macos-latest", gemfile: "3.3" } - { ruby: "3.4", os: "macos-latest", gemfile: "3.4" } @@ -292,9 +286,6 @@ jobs: - { ruby: "jruby", os: "macos-latest", gemfile: ".." } - { ruby: "truffleruby", os: "macos-latest", gemfile: ".." } - - { ruby: "2.7", os: "windows-latest", gemfile: "2.7" } - - { ruby: "3.0", os: "windows-latest", gemfile: "3.0" } - - { ruby: "3.1", os: "windows-latest", gemfile: "3.1" } - { ruby: "3.2", os: "windows-latest", gemfile: "3.2" } - { ruby: "3.3", os: "windows-latest", gemfile: "3.3" } - { ruby: "3.4", os: "windows-latest", gemfile: "3.4" } diff --git a/README.md b/README.md index e92ef7bfb3..c3494c3e35 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ To compile the shared library, you will need: * C99 compiler * GNU make -* Ruby 2.7.0 or later +* Ruby 3.2.0 or later Once you have these dependencies, run: diff --git a/bin/prism b/bin/prism index 43bdea1f36..93fe4d9da9 100755 --- a/bin/prism +++ b/bin/prism @@ -83,7 +83,6 @@ module Prism # bin/prism bundle [...] def bundle(argv) [ - ["3.1", ["3.1"]], ["3.2", ["3.2"]], ["3.3", ["3.3"]], ["3.4", ["3.4", "typecheck"]], diff --git a/docs/releasing.md b/docs/releasing.md index 6d0f892926..e836a1fd22 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -47,7 +47,7 @@ bundle install * Update the version-specific lockfiles: ```sh -for VERSION in "2.7" "3.0" "3.1" "3.2" "3.3" "3.4" "4.0"; do docker run -it --rm -v "$PWD":/usr/src/app -w /usr/src/app -e BUNDLE_GEMFILE="gemfiles/$VERSION/Gemfile" "ruby:$VERSION" bundle update; done +for VERSION in "3.2" "3.3" "3.4" "4.0"; do docker run -it --rm -v "$PWD":/usr/src/app -w /usr/src/app -e BUNDLE_GEMFILE="gemfiles/$VERSION/Gemfile" "ruby:$VERSION" bundle update; done chruby ruby-4.1.0-dev && BUNDLE_GEMFILE=gemfiles/4.1/Gemfile bundle install ``` diff --git a/gemfiles/2.7/Gemfile b/gemfiles/2.7/Gemfile deleted file mode 100644 index a3ac724e5e..0000000000 --- a/gemfiles/2.7/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -source "https://rubygems.org" - -ruby "~> 2.7.0" - -gemspec path: "../.." - -gem "onigmo", platforms: :ruby -gem "parser" -gem "rake-compiler" -gem "rake" -gem "ruby_parser" -gem "test-unit" diff --git a/gemfiles/2.7/Gemfile.lock b/gemfiles/2.7/Gemfile.lock deleted file mode 100644 index 7eab6a5528..0000000000 --- a/gemfiles/2.7/Gemfile.lock +++ /dev/null @@ -1,42 +0,0 @@ -PATH - remote: ../.. - specs: - prism (1.9.0) - -GEM - remote: https://rubygems.org/ - specs: - ast (2.4.3) - onigmo (0.1.0) - parser (3.3.10.2) - ast (~> 2.4.1) - racc - power_assert (3.0.1) - racc (1.8.1) - rake (13.3.1) - rake-compiler (1.3.1) - rake - ruby_parser (3.21.1) - racc (~> 1.5) - sexp_processor (~> 4.16) - sexp_processor (4.17.4) - test-unit (3.7.7) - power_assert - -PLATFORMS - ruby - -DEPENDENCIES - onigmo - parser - prism! - rake - rake-compiler - ruby_parser - test-unit - -RUBY VERSION - ruby 2.7.8p225 - -BUNDLED WITH - 2.1.4 diff --git a/gemfiles/3.0/Gemfile b/gemfiles/3.0/Gemfile deleted file mode 100644 index c5600d20f0..0000000000 --- a/gemfiles/3.0/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -source "https://rubygems.org" - -ruby "~> 3.0.0" - -gemspec path: "../.." - -gem "onigmo", platforms: :ruby -gem "parser" -gem "rake-compiler" -gem "rake" -gem "ruby_parser" -gem "test-unit" diff --git a/gemfiles/3.0/Gemfile.lock b/gemfiles/3.0/Gemfile.lock deleted file mode 100644 index d295f1f173..0000000000 --- a/gemfiles/3.0/Gemfile.lock +++ /dev/null @@ -1,42 +0,0 @@ -PATH - remote: ../.. - specs: - prism (1.9.0) - -GEM - remote: https://rubygems.org/ - specs: - ast (2.4.3) - onigmo (0.1.0) - parser (3.3.10.2) - ast (~> 2.4.1) - racc - power_assert (3.0.1) - racc (1.8.1) - rake (13.3.1) - rake-compiler (1.3.1) - rake - ruby_parser (3.21.1) - racc (~> 1.5) - sexp_processor (~> 4.16) - sexp_processor (4.17.4) - test-unit (3.7.7) - power_assert - -PLATFORMS - ruby - -DEPENDENCIES - onigmo - parser - prism! - rake - rake-compiler - ruby_parser - test-unit - -RUBY VERSION - ruby 3.0.6p216 - -BUNDLED WITH - 2.2.33 diff --git a/gemfiles/3.1/Gemfile b/gemfiles/3.1/Gemfile deleted file mode 100644 index 6f7e7b6a28..0000000000 --- a/gemfiles/3.1/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -source "https://rubygems.org" - -ruby "~> 3.1.0" - -gemspec path: "../.." - -gem "onigmo", platforms: :ruby -gem "parser" -gem "rake-compiler" -gem "rake" -gem "ruby_parser" -gem "test-unit" diff --git a/gemfiles/3.1/Gemfile.lock b/gemfiles/3.1/Gemfile.lock deleted file mode 100644 index 3b242f5c3c..0000000000 --- a/gemfiles/3.1/Gemfile.lock +++ /dev/null @@ -1,42 +0,0 @@ -PATH - remote: ../.. - specs: - prism (1.9.0) - -GEM - remote: https://rubygems.org/ - specs: - ast (2.4.3) - onigmo (0.1.0) - parser (3.3.10.2) - ast (~> 2.4.1) - racc - power_assert (3.0.1) - racc (1.8.1) - rake (13.3.1) - rake-compiler (1.3.1) - rake - ruby_parser (3.21.1) - racc (~> 1.5) - sexp_processor (~> 4.16) - sexp_processor (4.17.4) - test-unit (3.7.7) - power_assert - -PLATFORMS - ruby - -DEPENDENCIES - onigmo - parser - prism! - rake - rake-compiler - ruby_parser - test-unit - -RUBY VERSION - ruby 3.1.4p223 - -BUNDLED WITH - 2.3.27 diff --git a/lib/prism.rb b/lib/prism.rb index 6b34ab12bf..81e890dacf 100644 --- a/lib/prism.rb +++ b/lib/prism.rb @@ -108,8 +108,6 @@ def self.load(source, serialized, freeze = false) # def self.parse_file_failure?: (String filepath, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?scopes: Array[Array[Symbol]], ?version: String) -> bool end -require_relative "prism/polyfill/byteindex" -require_relative "prism/polyfill/warn" require_relative "prism/node" require_relative "prism/node_ext" require_relative "prism/parse_result" diff --git a/lib/prism/polyfill/byteindex.rb b/lib/prism/polyfill/byteindex.rb deleted file mode 100644 index 98c6089f14..0000000000 --- a/lib/prism/polyfill/byteindex.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Polyfill for String#byteindex, which didn't exist until Ruby 3.2. -if !("".respond_to?(:byteindex)) - String.include( - Module.new { - def byteindex(needle, offset = 0) - charindex = index(needle, offset) - slice(0...charindex).bytesize if charindex - end - } - ) -end diff --git a/lib/prism/polyfill/unpack1.rb b/lib/prism/polyfill/unpack1.rb deleted file mode 100644 index 3fa9b5a0c5..0000000000 --- a/lib/prism/polyfill/unpack1.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# Polyfill for String#unpack1 with the offset parameter. Not all Ruby engines -# have Method#parameters implemented, so we check the arity instead if -# necessary. -if (unpack1 = String.instance_method(:unpack1)).respond_to?(:parameters) ? unpack1.parameters.none? { |_, name| name == :offset } : (unpack1.arity == 1) - String.prepend( - Module.new { - def unpack1(format, offset: 0) # :nodoc: - offset == 0 ? super(format) : self[offset..].unpack1(format) # steep:ignore - end - } - ) -end diff --git a/lib/prism/polyfill/warn.rb b/lib/prism/polyfill/warn.rb deleted file mode 100644 index 76a4264623..0000000000 --- a/lib/prism/polyfill/warn.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -# Polyfill for Kernel#warn with the category parameter. Not all Ruby engines -# have Method#parameters implemented, so we check the arity instead if -# necessary. -if (method = Kernel.instance_method(:warn)).respond_to?(:parameters) ? method.parameters.none? { |_, name| name == :category } : (method.arity == -1) - Kernel.prepend( - Module.new { - def warn(*msgs, uplevel: nil, category: nil) # :nodoc: - case uplevel - when nil - super(*msgs) - when Integer - super(*msgs, uplevel: uplevel + 1) - else - super(*msgs, uplevel: uplevel.to_int + 1) - end - end - } - ) - - Object.prepend( - Module.new { - def warn(*msgs, uplevel: nil, category: nil) # :nodoc: - case uplevel - when nil - super(*msgs) - when Integer - super(*msgs, uplevel: uplevel + 1) - else - super(*msgs, uplevel: uplevel.to_int + 1) - end - end - } - ) -end diff --git a/prism.gemspec b/prism.gemspec index d8b86c6fba..752f6e2b46 100644 --- a/prism.gemspec +++ b/prism.gemspec @@ -10,7 +10,7 @@ Gem::Specification.new do |spec| spec.homepage = "https://github.com/ruby/prism" spec.license = "MIT" - spec.required_ruby_version = ">= 2.7.0" + spec.required_ruby_version = ">= 3.2.0" spec.require_paths = ["lib"] spec.files = [ @@ -88,10 +88,7 @@ Gem::Specification.new do |spec| "lib/prism/parse_result/newlines.rb", "lib/prism/pattern.rb", "lib/prism/polyfill/append_as_bytes.rb", - "lib/prism/polyfill/byteindex.rb", "lib/prism/polyfill/scan_byte.rb", - "lib/prism/polyfill/unpack1.rb", - "lib/prism/polyfill/warn.rb", "lib/prism/reflection.rb", "lib/prism/relocation.rb", "lib/prism/serialize.rb", diff --git a/rakelib/test.rake b/rakelib/test.rake index 4257202bc8..d1898e995e 100644 --- a/rakelib/test.rake +++ b/rakelib/test.rake @@ -43,9 +43,6 @@ end # memcheck or debug tests. return if RUBY_ENGINE == "jruby" || RUBY_ENGINE == "truffleruby" -# Don't bother trying to configure memcheck on old versions of Ruby. -return if RUBY_VERSION < "3.0" - # Only attempt to configure memcheck if the gem is installed. begin require "ruby_memcheck" diff --git a/templates/lib/prism/serialize.rb.erb b/templates/lib/prism/serialize.rb.erb index c272d84bb4..17b4325ca7 100644 --- a/templates/lib/prism/serialize.rb.erb +++ b/templates/lib/prism/serialize.rb.erb @@ -2,7 +2,6 @@ # rbs_inline: enabled require "stringio" -require_relative "polyfill/unpack1" module Prism # A module responsible for deserializing parse results. diff --git a/test/prism/encoding/regular_expression_encoding_test.rb b/test/prism/encoding/regular_expression_encoding_test.rb index fdff1e3281..fc4eb17976 100644 --- a/test/prism/encoding/regular_expression_encoding_test.rb +++ b/test/prism/encoding/regular_expression_encoding_test.rb @@ -2,7 +2,6 @@ return unless defined?(RubyVM::InstructionSequence) return if RubyVM::InstructionSequence.compile("").to_a[4][:parser] == :prism -return if RUBY_VERSION < "3.2" require_relative "../test_helper" diff --git a/test/prism/fixtures_test.rb b/test/prism/fixtures_test.rb index dcbcb7c117..dd0be16db1 100644 --- a/test/prism/fixtures_test.rb +++ b/test/prism/fixtures_test.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -return if RUBY_VERSION < "3.2.0" - require_relative "test_helper" module Prism diff --git a/test/prism/lex_test.rb b/test/prism/lex_test.rb index 8ea7ce7e9b..f740f1754c 100644 --- a/test/prism/lex_test.rb +++ b/test/prism/lex_test.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -return if !(RUBY_ENGINE == "ruby" && RUBY_VERSION >= "3.2.0") - require_relative "test_helper" require "ripper" diff --git a/test/prism/result/warnings_test.rb b/test/prism/result/warnings_test.rb index 27f1119b98..89f8a5526c 100644 --- a/test/prism/result/warnings_test.rb +++ b/test/prism/result/warnings_test.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -return if RUBY_VERSION < "3.1" - require_relative "../test_helper" module Prism diff --git a/test/prism/ruby/parameters_signature_test.rb b/test/prism/ruby/parameters_signature_test.rb index 5a225862c3..aa967cf9b3 100644 --- a/test/prism/ruby/parameters_signature_test.rb +++ b/test/prism/ruby/parameters_signature_test.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -return if RUBY_VERSION < "3.2" - require_relative "../test_helper" module Prism diff --git a/test/prism/unescape_test.rb b/test/prism/unescape_test.rb index d241f28c08..0ba823bffa 100644 --- a/test/prism/unescape_test.rb +++ b/test/prism/unescape_test.rb @@ -3,7 +3,6 @@ require_relative "test_helper" return if Prism::BACKEND == :FFI -return if RUBY_VERSION < "3.1.0" return if RUBY_VERSION >= "3.4.0" module Prism