Skip to content

Commit b79152f

Browse files
committed
[ruby/prism] Support 3.5 for version option
ruby/prism@6b6aa05bfb
1 parent 76b620b commit b79152f

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

lib/prism/ffi.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ def dump_options_version(version)
431431
when /\A3\.3(\.\d+)?\z/
432432
1
433433
when /\A3\.4(\.\d+)?\z/
434+
2
435+
when /\A3\.5(\.\d+)?\z/
434436
0
435437
else
436438
raise ArgumentError, "invalid version: #{version}"

prism/options.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ pm_options_version_set(pm_options_t *options, const char *version, size_t length
8484
}
8585

8686
if (strncmp(version, "3.4", 3) == 0) {
87+
options->version = PM_OPTIONS_VERSION_CRUBY_3_4;
88+
return true;
89+
}
90+
91+
if (strncmp(version, "3.5", 3) == 0) {
8792
options->version = PM_OPTIONS_VERSION_LATEST;
8893
return true;
8994
}
@@ -98,6 +103,11 @@ pm_options_version_set(pm_options_t *options, const char *version, size_t length
98103
}
99104

100105
if (strncmp(version, "3.4.", 4) == 0 && is_number(version + 4, length - 4)) {
106+
options->version = PM_OPTIONS_VERSION_CRUBY_3_4;
107+
return true;
108+
}
109+
110+
if (strncmp(version, "3.5.", 4) == 0 && is_number(version + 4, length - 4)) {
101111
options->version = PM_OPTIONS_VERSION_LATEST;
102112
return true;
103113
}

prism/options.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ typedef enum {
6868
PM_OPTIONS_VERSION_LATEST = 0,
6969

7070
/** The vendored version of prism in CRuby 3.3.x. */
71-
PM_OPTIONS_VERSION_CRUBY_3_3 = 1
71+
PM_OPTIONS_VERSION_CRUBY_3_3 = 1,
72+
73+
/** The vendored version of prism in CRuby 3.4.x. */
74+
PM_OPTIONS_VERSION_CRUBY_3_4 = 2
7275
} pm_options_version_t;
7376

7477
/**

test/prism/api/parse_test.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ def test_version
116116
assert Prism.parse_success?("1 + 1", version: "3.4.9")
117117
assert Prism.parse_success?("1 + 1", version: "3.4.10")
118118

119+
assert Prism.parse_success?("1 + 1", version: "3.5")
120+
assert Prism.parse_success?("1 + 1", version: "3.5.0")
121+
119122
assert Prism.parse_success?("1 + 1", version: "latest")
120123

121124
# Test edge case
@@ -133,7 +136,7 @@ def test_version
133136

134137
# Not supported version (too new)
135138
assert_raise ArgumentError do
136-
Prism.parse("1 + 1", version: "3.5.0")
139+
Prism.parse("1 + 1", version: "3.6.0")
137140
end
138141
end
139142

0 commit comments

Comments
 (0)