aboutsummaryrefslogtreecommitdiffstats
path: root/yarp/yarp.c
diff options
context:
space:
mode:
authorJemma Issroff <jemmaissroff@gmail.com>2023-06-21 12:59:22 -0400
committerTakashi Kokubun <takashikkbn@gmail.com>2023-06-22 09:20:40 -0700
commite8fb84265c897d5e64b1fcb71054ef7eebe13262 (patch)
tree969818ba6caeaa576a1daa03741de3feeea7cdeb /yarp/yarp.c
parent7fad7d345acae5a44bc12c1ee98220b83f6f249c (diff)
downloadruby-e8fb84265c897d5e64b1fcb71054ef7eebe13262.tar.gz
[ruby/yarp] Allow for block statements after elsif and else
https://github.com/ruby/yarp/commit/4560cab235
Diffstat (limited to 'yarp/yarp.c')
-rw-r--r--yarp/yarp.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/yarp/yarp.c b/yarp/yarp.c
index 0475c44836..c4fe886a72 100644
--- a/yarp/yarp.c
+++ b/yarp/yarp.c
@@ -8701,7 +8701,10 @@ parse_conditional(yp_parser_t *parser, yp_context_t context) {
accept_any(parser, 2, YP_TOKEN_NEWLINE, YP_TOKEN_SEMICOLON);
accept(parser, YP_TOKEN_KEYWORD_THEN);
+ yp_accepts_block_stack_push(parser, true);
yp_statements_node_t *statements = parse_statements(parser, YP_CONTEXT_ELSIF);
+ yp_accepts_block_stack_pop(parser);
+
accept_any(parser, 2, YP_TOKEN_NEWLINE, YP_TOKEN_SEMICOLON);
yp_node_t *elsif = (yp_node_t *) yp_if_node_create(parser, &elsif_keyword, predicate, statements, NULL, &end_keyword);
@@ -8713,7 +8716,10 @@ parse_conditional(yp_parser_t *parser, yp_context_t context) {
if (match_type_p(parser, YP_TOKEN_KEYWORD_ELSE)) {
parser_lex(parser);
yp_token_t else_keyword = parser->previous;
+
+ yp_accepts_block_stack_push(parser, true);
yp_statements_node_t *else_statements = parse_statements(parser, YP_CONTEXT_ELSE);
+ yp_accepts_block_stack_pop(parser);
accept_any(parser, 2, YP_TOKEN_NEWLINE, YP_TOKEN_SEMICOLON);
expect(parser, YP_TOKEN_KEYWORD_END, "Expected `end` to close `else` clause.");