summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-10-05 13:42:17 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-10-05 15:00:02 +0900
commit126122bb6c83cca5eac6c71e3e75e3f647397d94 (patch)
treeb82a83eea2d05536494195c66f7e52bb5d4a41e8 /parse.y
parent0553494ad7ccbc75ac954c2cb0e7ea50443bad0c (diff)
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.
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y3
1 files changed, 3 insertions, 0 deletions
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 {
(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))