diff options
author | Koichi ITO <[email protected]> | 2024-02-14 02:38:35 +0900 |
---|---|---|
committer | git <[email protected]> | 2024-02-13 18:15:48 +0000 |
commit | 246005f5bd3171e12bafe820d183a7a23adc9e96 (patch) | |
tree | 7adc003cc74d6d88dc410a034f81ccd599442902 /prism/options.c | |
parent | a93f4e3d1a656861897a244f34f9cdbc0d7fea49 (diff) |
[ruby/prism] Fix an error when specifying the parsing version `latest`
This PR fixes following error when using `version: latest` argument.
```console
$ ruby -rprism -e "p Prism.parse('-> { it }', version: 'latest')"
-e:1:in `parse': invalid version: latest (ArgumentError)
p Prism.parse('-> { it }', version: 'latest')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
from -e:1:in `<main>'
```
The argument `version: latest` in the added test is commented as potentially being
better replaced with `version: 3.4.0` in the future.
https://github.com/ruby/prism/commit/27b5c933cb
Diffstat (limited to 'prism/options.c')
-rw-r--r-- | prism/options.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/prism/options.c b/prism/options.c index 4187abf9fa..ae5b5a8d3c 100644 --- a/prism/options.c +++ b/prism/options.c @@ -44,16 +44,14 @@ pm_options_version_set(pm_options_t *options, const char *version, size_t length return true; } - if (length == 5) { - if (strncmp(version, "3.3.0", 5) == 0) { - options->version = PM_OPTIONS_VERSION_CRUBY_3_3_0; - return true; - } + if (length == 5 && strncmp(version, "3.3.0", length) == 0) { + options->version = PM_OPTIONS_VERSION_CRUBY_3_3_0; + return true; + } - if (strncmp(version, "latest", 6) == 0) { - options->version = PM_OPTIONS_VERSION_LATEST; - return true; - } + if (length == 6 && strncmp(version, "latest", length) == 0) { + options->version = PM_OPTIONS_VERSION_LATEST; + return true; } return false; |