diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2026-01-28 21:23:15 -0500 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2026-01-29 02:35:38 +0000 |
| commit | fa09afb15c9cf901d84e2963b86c4c7a7d0e104e (patch) | |
| tree | b8446fdceae0f231520b5100e7c2a86d2e9b25d4 /lib | |
| parent | 0c30897d0bf579ee7be08fc828932e1bac1196aa (diff) | |
[ruby/prism] Support `version: "nearest"`.
This clamps to supported versions based on the current Ruby version.
https://github.com/ruby/prism/commit/eb63748e8b
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/prism/ffi.rb | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/prism/ffi.rb b/lib/prism/ffi.rb index d4c9d60c9a..57d878a33f 100644 --- a/lib/prism/ffi.rb +++ b/lib/prism/ffi.rb @@ -423,10 +423,26 @@ module Prism # Return the value that should be dumped for the version option. def dump_options_version(version) - current = version == "current" + checking = + case version + when "current" + RUBY_VERSION + when "latest" + nil + when "nearest" + if RUBY_VERSION <= "3.3" + "3.3" + elsif RUBY_VERSION >= "4.1" + "4.1" + else + RUBY_VERSION + end + else + version + end - case current ? RUBY_VERSION : version - when nil, "latest" + case checking + when nil 0 # Handled in pm_parser_init when /\A3\.3(\.\d+)?\z/ 1 @@ -437,7 +453,7 @@ module Prism when /\A4\.1(\.\d+)?\z/ 4 else - if current + if version == "current" raise CurrentVersionError, RUBY_VERSION else raise ArgumentError, "invalid version: #{version}" |
