diff --git a/parse.y b/parse.y index f37bb59c601bdf..f135554e1dc87f 100644 --- a/parse.y +++ b/parse.y @@ -7443,6 +7443,23 @@ parser_precise_mbclen(struct parser_params *p, const char *ptr) } #ifndef RIPPER +static inline void +parser_show_error_line(struct parser_params *p, const YYLTYPE *yylloc) +{ + rb_parser_string_t *str; + int lineno = p->ruby_sourceline; + if (!yylloc) { + return; + } + else if (yylloc->beg_pos.lineno == lineno) { + str = p->lex.lastline; + } + else { + return; + } + ruby_show_error_line(p, p->error_buffer, Qnil, yylloc, lineno, str); +} + static int parser_yyerror(struct parser_params *p, const rb_code_location_t *yylloc, const char *msg) { @@ -16243,6 +16260,7 @@ parser_compile_error(struct parser_params *p, const rb_code_location_t *loc, con p->ruby_sourcefile_string, lineno, column, p->enc, fmt, ap); + parser_show_error_line(p, loc); } else { VALUE str = rb_enc_str_new(0, 0, p->enc);