From dd7f0c87c9da8e695c38a6529deb6e0f24f6d06c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 20 Dec 2019 23:36:19 +0900 Subject: Hoisted out new_case3 --- parse.y | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/parse.y b/parse.y index 9f7e3a650d..3aaa29111a 100644 --- a/parse.y +++ b/parse.y @@ -472,6 +472,7 @@ static NODE *new_array_pattern(struct parser_params *p, NODE *constant, NODE *pr static NODE *new_array_pattern_tail(struct parser_params *p, NODE *pre_args, int has_rest, ID rest_arg, NODE *post_args, const YYLTYPE *loc); static NODE *new_hash_pattern(struct parser_params *p, NODE *constant, NODE *hshptn, const YYLTYPE *loc); static NODE *new_hash_pattern_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, const YYLTYPE *loc); +static NODE *new_case3(struct parser_params *p, NODE *val, NODE *pat, const YYLTYPE *loc); static NODE *new_kw_arg(struct parser_params *p, NODE *k, const YYLTYPE *loc); static NODE *args_with_numbered(struct parser_params*,NODE*,int); @@ -1572,8 +1573,7 @@ expr : command_call { p->in_kwarg = !!$3; /*%%%*/ - $$ = NEW_CASE3($1, NEW_IN($5, 0, 0, &@5), &@$); - rb_warn0L(nd_line($$), "Pattern matching is experimental, and the behavior may change in future versions of Ruby!"); + $$ = new_case3(p, $1, NEW_IN($5, 0, 0, &@5), &@$); /*% %*/ /*% ripper: case!($1, in!($5, Qnil, Qnil)) %*/ } @@ -2860,8 +2860,7 @@ primary : literal k_end { /*%%%*/ - $$ = NEW_CASE3($2, $4, &@$); - rb_warn0L(nd_line($$), "Pattern matching is experimental, and the behavior may change in future versions of Ruby!"); + $$ = new_case3(p, $2, $4, &@$); /*% %*/ /*% ripper: case!($2, $4) %*/ } @@ -11453,6 +11452,15 @@ new_hash_pattern_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, co return node; } +static NODE * +new_case3(struct parser_params *p, NODE *val, NODE *pat, const YYLTYPE *loc) +{ + NODE *node = NEW_CASE3(val, pat, loc); + + rb_warn0L(nd_line(node), "Pattern matching is experimental, and the behavior may change in future versions of Ruby!"); + return node; +} + static NODE* dsym_node(struct parser_params *p, NODE *node, const YYLTYPE *loc) { -- cgit v1.2.3