Skip to content

Commit 54606b8

Browse files
committed
Reverse-sync ruby/ruby@f4e0178
1 parent a156df0 commit 54606b8

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

include/prism/options.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,11 @@ typedef enum {
9494
/** The vendored version of prism in CRuby 3.5.x. */
9595
PM_OPTIONS_VERSION_CRUBY_3_5 = 3,
9696

97+
/** The vendored version of prism in CRuby 4.0.x. */
98+
PM_OPTIONS_VERSION_CRUBY_4_0 = 4,
99+
97100
/** The current version of prism. */
98-
PM_OPTIONS_VERSION_LATEST = PM_OPTIONS_VERSION_CRUBY_3_5
101+
PM_OPTIONS_VERSION_LATEST = PM_OPTIONS_VERSION_CRUBY_4_0
99102
} pm_options_version_t;
100103

101104
/**

lib/prism/ffi.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,8 @@ def dump_options_version(version)
434434
2
435435
when /\A3\.5(\.\d+)?\z/
436436
3
437+
when /\A4\.0(\.\d+)?\z/
438+
4
437439
else
438440
if current
439441
raise CurrentVersionError, RUBY_VERSION

src/options.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ pm_options_version_set(pm_options_t *options, const char *version, size_t length
9393
return true;
9494
}
9595

96+
if (strncmp(version, "4.0", 3) == 0) {
97+
options->version = PM_OPTIONS_VERSION_CRUBY_4_0;
98+
return true;
99+
}
100+
96101
return false;
97102
}
98103

@@ -111,6 +116,11 @@ pm_options_version_set(pm_options_t *options, const char *version, size_t length
111116
options->version = PM_OPTIONS_VERSION_CRUBY_3_5;
112117
return true;
113118
}
119+
120+
if (strncmp(version, "4.0.", 4) == 0 && is_number(version + 4, length - 4)) {
121+
options->version = PM_OPTIONS_VERSION_CRUBY_4_0;
122+
return true;
123+
}
114124
}
115125

116126
if (length >= 6) {

test/prism/test_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def self.windows?
230230
end
231231

232232
# All versions that prism can parse
233-
SYNTAX_VERSIONS = %w[3.3 3.4 3.5]
233+
SYNTAX_VERSIONS = %w[3.3 3.4 3.5 4.0]
234234

235235
# Returns an array of ruby versions that a given filepath should test against:
236236
# test.txt # => all available versions

0 commit comments

Comments
 (0)