summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2024-12-28 11:25:57 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2024-12-28 11:25:57 +0900
commitfb18bb183c24ca82b8f114ed090d62bd69b5df84 (patch)
treec1a34231fbb8d16e8537af5ca9805d7cc72ab0ab /parse.y
parent827a19e7781ea2308787f3bb14bfe57b4fcc07f6 (diff)
[Bug #20989] Ripper: Pass `compile_error`
For the universal parser, `rb_parser_reg_fragment_check` function is shared between the parser and ripper. However `parser_params` struct is partially different, and `compile_error` function depends on that part indirectly.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12482
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y17
1 files changed, 12 insertions, 5 deletions
diff --git a/parse.y b/parse.y
index cbce831c5b..b238f8d651 100644
--- a/parse.y
+++ b/parse.y
@@ -1480,8 +1480,9 @@ static rb_ast_id_table_t *local_tbl(struct parser_params*);
static VALUE reg_compile(struct parser_params*, rb_parser_string_t*, int);
static void reg_fragment_setenc(struct parser_params*, rb_parser_string_t*, int);
-#define reg_fragment_check rb_parser_reg_fragment_check
-int reg_fragment_check(struct parser_params*, rb_parser_string_t*, int);
+int rb_parser_reg_fragment_check(struct parser_params*, rb_parser_string_t*, int, rb_parser_reg_fragment_error_func);
+static void reg_fragment_error(struct parser_params *, VALUE);
+#define reg_fragment_check(p, str, option) rb_parser_reg_fragment_check(p, str, option, reg_fragment_error)
static int literal_concat0(struct parser_params *p, rb_parser_string_t *head, rb_parser_string_t *tail);
static NODE *heredoc_dedent(struct parser_params*,NODE*);
@@ -15378,9 +15379,15 @@ reg_fragment_setenc(struct parser_params* p, rb_parser_string_t *str, int option
if (c) reg_fragment_enc_error(p, str, c);
}
+static void
+reg_fragment_error(struct parser_params* p, VALUE err)
+{
+ compile_error(p, "%"PRIsVALUE, err);
+}
+
#ifndef RIPPER
int
-reg_fragment_check(struct parser_params* p, rb_parser_string_t *str, int options)
+rb_parser_reg_fragment_check(struct parser_params* p, rb_parser_string_t *str, int options, rb_parser_reg_fragment_error_func error)
{
VALUE err, str2;
reg_fragment_setenc(p, str, options);
@@ -15389,7 +15396,7 @@ reg_fragment_check(struct parser_params* p, rb_parser_string_t *str, int options
err = rb_reg_check_preprocess(str2);
if (err != Qnil) {
err = rb_obj_as_string(err);
- compile_error(p, "%"PRIsVALUE, err);
+ error(p, err);
return 0;
}
return 1;
@@ -15494,7 +15501,7 @@ reg_compile(struct parser_params* p, rb_parser_string_t *str, int options)
if (NIL_P(re)) {
VALUE m = rb_attr_get(rb_errinfo(), idMesg);
rb_set_errinfo(err);
- compile_error(p, "%"PRIsVALUE, m);
+ reg_fragment_error(p, m);
return Qnil;
}
return re;