mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
Explicitly use a ruby version for prism to parse the code as
Prism can parse multiple versions of ruby. Because of that branch release managers are ok with simply bumping prism to its latest version. However, if no version is specified, it will parse as the latest known version, which can be ahead of the maintenance branch. So we need to explicitly pass a version to not accidentally introduce new syntax to maintenance branches.
This commit is contained in:
parent
52b3f006cb
commit
c63d6bee7b
@ -3425,6 +3425,7 @@ compile.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
|
||||
compile.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
|
||||
compile.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
|
||||
compile.$(OBJEXT): $(top_srcdir)/prism_compile.c
|
||||
compile.$(OBJEXT): $(top_srcdir)/version.h
|
||||
compile.$(OBJEXT): {$(VPATH)}assert.h
|
||||
compile.$(OBJEXT): {$(VPATH)}atomic.h
|
||||
compile.$(OBJEXT): {$(VPATH)}backward/2/assume.h
|
||||
@ -3618,6 +3619,7 @@ compile.$(OBJEXT): {$(VPATH)}prism_compile.h
|
||||
compile.$(OBJEXT): {$(VPATH)}ractor.h
|
||||
compile.$(OBJEXT): {$(VPATH)}re.h
|
||||
compile.$(OBJEXT): {$(VPATH)}regex.h
|
||||
compile.$(OBJEXT): {$(VPATH)}revision.h
|
||||
compile.$(OBJEXT): {$(VPATH)}ruby_assert.h
|
||||
compile.$(OBJEXT): {$(VPATH)}ruby_atomic.h
|
||||
compile.$(OBJEXT): {$(VPATH)}rubyparser.h
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include "prism.h"
|
||||
#include "version.h"
|
||||
|
||||
/**
|
||||
* This compiler defines its own concept of the location of a node. We do this
|
||||
@ -11351,6 +11352,8 @@ pm_parse_file(pm_parse_result_t *result, VALUE filepath, VALUE *script_lines)
|
||||
pm_options_filepath_set(&result->options, RSTRING_PTR(filepath));
|
||||
RB_GC_GUARD(filepath);
|
||||
|
||||
pm_options_version_for_current_ruby_set(&result->options);
|
||||
|
||||
pm_parser_init(&result->parser, pm_string_source(&result->input), pm_string_length(&result->input), &result->options);
|
||||
pm_node_t *node = pm_parse(&result->parser);
|
||||
|
||||
@ -11409,6 +11412,8 @@ pm_parse_string(pm_parse_result_t *result, VALUE source, VALUE filepath, VALUE *
|
||||
pm_options_filepath_set(&result->options, RSTRING_PTR(filepath));
|
||||
RB_GC_GUARD(filepath);
|
||||
|
||||
pm_options_version_for_current_ruby_set(&result->options);
|
||||
|
||||
pm_parser_init(&result->parser, pm_string_source(&result->input), pm_string_length(&result->input), &result->options);
|
||||
pm_node_t *node = pm_parse(&result->parser);
|
||||
|
||||
@ -11491,6 +11496,13 @@ pm_parse_stdin(pm_parse_result_t *result)
|
||||
return pm_parse_process(result, node, NULL);
|
||||
}
|
||||
|
||||
#define PM_VERSION_FOR_RELEASE(major, minor) PM_VERSION_FOR_RELEASE_IMPL(major, minor)
|
||||
#define PM_VERSION_FOR_RELEASE_IMPL(major, minor) PM_OPTIONS_VERSION_CRUBY_##major##_##minor
|
||||
|
||||
void pm_options_version_for_current_ruby_set(pm_options_t *options) {
|
||||
options->version = PM_VERSION_FOR_RELEASE(RUBY_VERSION_MAJOR, RUBY_VERSION_MINOR);
|
||||
}
|
||||
|
||||
#undef NEW_ISEQ
|
||||
#define NEW_ISEQ OLD_ISEQ
|
||||
|
||||
|
||||
@ -94,6 +94,7 @@ VALUE pm_parse_file(pm_parse_result_t *result, VALUE filepath, VALUE *script_lin
|
||||
VALUE pm_load_parse_file(pm_parse_result_t *result, VALUE filepath, VALUE *script_lines);
|
||||
VALUE pm_parse_string(pm_parse_result_t *result, VALUE source, VALUE filepath, VALUE *script_lines);
|
||||
VALUE pm_parse_stdin(pm_parse_result_t *result);
|
||||
void pm_options_version_for_current_ruby_set(pm_options_t *options);
|
||||
void pm_parse_result_free(pm_parse_result_t *result);
|
||||
|
||||
rb_iseq_t *pm_iseq_new(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, enum rb_iseq_type, int *error_state);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user