[前][次][番号順一覧][スレッド一覧]

ruby-changes:68264

From: Nobuyoshi <ko1@a...>
Date: Tue, 5 Oct 2021 15:19:33 +0900 (JST)
Subject: [ruby-changes:68264] 126122bb6c (master): Replace inaccurate error messages

https://git.ruby-lang.org/ruby.git/commit/?id=126122bb6c

From 126122bb6c83cca5eac6c71e3e75e3f647397d94 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Tue, 5 Oct 2021 13:42:17 +0900
Subject: Replace inaccurate error messages

When Bison reports "memory exhausted", it means the parser stack
depth reached the limit `YYMAXDEPTH` which is defaulted to 10_000,
but not memory allocation failed.
---
 parse.y | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/parse.y b/parse.y
index d7261a008d..3d5ba3b1ea 100644
--- a/parse.y
+++ b/parse.y
@@ -105,6 +105,9 @@ struct lex_context { https://github.com/ruby/ruby/blob/trunk/parse.y#L105
           (Current).end_pos = YYRHSLOC(Rhs, 0).end_pos;                 \
         }                                                               \
     while (0)
+#define YY_(Msgid) \
+    (((Msgid)[0] == 'm') && (strcmp((Msgid), "memory exhausted") == 0) ? \
+     "nesting too deep" : (Msgid))
 
 #define RUBY_SET_YYLLOC_FROM_STRTERM_HEREDOC(Current)			\
     rb_parser_set_location_from_strterm_heredoc(p, &p->lex.strterm->u.heredoc, &(Current))
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]