aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-12-25 14:47:31 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-12-25 14:49:48 +0900
commit56e002981fab73a94c6038cb9de82aba6ff84eb4 (patch)
treeccb29c64c9ca202007be9e8c0a677479078cbb54
parent9808e010907bb16068497d9f0f8593a7165fa42d (diff)
downloadruby-56e002981fab73a94c6038cb9de82aba6ff84eb4.tar.gz
Show the error line only when same as the current
-rw-r--r--parse.y13
1 files changed, 12 insertions, 1 deletions
diff --git a/parse.y b/parse.y
index 6d9bfc9f41..1281eb6258 100644
--- a/parse.y
+++ b/parse.y
@@ -5631,7 +5631,18 @@ static void ruby_show_error_line(VALUE errbuf, const YYLTYPE *yylloc, int lineno
static inline void
parser_show_error_line(struct parser_params *p, const YYLTYPE *yylloc)
{
- ruby_show_error_line(p->error_buffer, yylloc, p->ruby_sourceline, p->lex.lastline);
+ VALUE 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->error_buffer, yylloc, lineno, str);
}
static int