summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorKazuki Tsujimoto <kazuki@callcc.net>2020-11-01 13:28:24 +0900
committerKazuki Tsujimoto <kazuki@callcc.net>2020-11-01 13:33:58 +0900
commitb60153241121297c94de976419d421683da4d51b (patch)
treeb1c1c8f8ca5d89f72de73d1fece79c4d490fb8df /parse.y
parent4f8d9b0db84c42c8d37f75de885de1c0a5cb542c (diff)
Pattern matching is no longer experimental
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y22
1 files changed, 9 insertions, 13 deletions
diff --git a/parse.y b/parse.y
index 256e9915ad..98fd4ae921 100644
--- a/parse.y
+++ b/parse.y
@@ -502,7 +502,6 @@ static NODE *new_find_pattern(struct parser_params *p, NODE *constant, NODE *fnd
static NODE *new_find_pattern_tail(struct parser_params *p, ID pre_rest_arg, NODE *args, ID post_rest_arg, 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);
@@ -1661,7 +1660,11 @@ expr : command_call
{
p->ctxt.in_kwarg = $<ctxt>3.in_kwarg;
/*%%%*/
- $$ = new_case3(p, $1, NEW_IN($5, 0, 0, &@5), &@$);
+ $$ = NEW_CASE3($1, NEW_IN($5, 0, 0, &@5), &@$);
+
+ if (rb_warning_category_enabled_p(RB_WARN_CATEGORY_EXPERIMENTAL))
+ rb_warn0L(nd_line($$), "One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!");
+
/*% %*/
/*% ripper: case!($1, in!($5, Qnil, Qnil)) %*/
}
@@ -2998,7 +3001,7 @@ primary : literal
k_end
{
/*%%%*/
- $$ = new_case3(p, $2, $4, &@$);
+ $$ = NEW_CASE3($2, $4, &@$);
/*% %*/
/*% ripper: case!($2, $4) %*/
}
@@ -4176,6 +4179,9 @@ p_args_tail : p_rest
p_find : p_rest ',' p_args_post ',' p_rest
{
$$ = new_find_pattern_tail(p, $1, $3, $5, &@$);
+
+ if (rb_warning_category_enabled_p(RB_WARN_CATEGORY_EXPERIMENTAL))
+ rb_warn0L(nd_line($$), "Find pattern is experimental, and the behavior may change in future versions of Ruby!");
}
;
@@ -11679,16 +11685,6 @@ 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);
-
- if (rb_warning_category_enabled_p(RB_WARN_CATEGORY_EXPERIMENTAL))
- 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)
{