[ruby/prism] Introduce version: "3.4.0"

This is effectively an alias for "latest" right now. In the future
it will change to be its own enum value.

https://github.com/ruby/prism/commit/2c86036022
This commit is contained in:
Kevin Newton 2024-02-13 13:19:02 -05:00 committed by git
parent 246005f5bd
commit 29d04bb0c4
3 changed files with 12 additions and 6 deletions

View File

@ -317,7 +317,7 @@ module Prism
values << (options.fetch(:frozen_string_literal, false) ? 1 : 0)
template << "C"
values << { nil => 0, "3.3.0" => 1, "latest" => 0 }.fetch(options[:version])
values << { nil => 0, "3.3.0" => 1, "3.4.0" => 0, "latest" => 0 }.fetch(options[:version])
template << "L"
if (scopes = options[:scopes])

View File

@ -44,9 +44,16 @@ pm_options_version_set(pm_options_t *options, const char *version, size_t length
return true;
}
if (length == 5 && strncmp(version, "3.3.0", length) == 0) {
options->version = PM_OPTIONS_VERSION_CRUBY_3_3_0;
return true;
if (length == 5) {
if (strncmp(version, "3.3.0", length) == 0) {
options->version = PM_OPTIONS_VERSION_CRUBY_3_3_0;
return true;
}
if (strncmp(version, "3.4.0", length) == 0) {
options->version = PM_OPTIONS_VERSION_LATEST;
return true;
}
}
if (length == 6 && strncmp(version, "latest", length) == 0) {

View File

@ -179,8 +179,7 @@ module Prism
node.body.body.first
end
# TODO: Please consider using `version: 3.4.0` instead of `version: latest` in the future.
assert_location(LocalVariableReadNode, "-> { it }", 5...7, version: "latest") do |node|
assert_location(LocalVariableReadNode, "-> { it }", 5...7, version: "3.4.0") do |node|
node.body.body.first
end
end