diff options
author | Kazuki Tsujimoto <kazuki@callcc.net> | 2020-11-01 13:28:24 +0900 |
---|---|---|
committer | Kazuki Tsujimoto <kazuki@callcc.net> | 2020-11-01 13:33:58 +0900 |
commit | b60153241121297c94de976419d421683da4d51b (patch) | |
tree | b1c1c8f8ca5d89f72de73d1fece79c4d490fb8df /parse.y | |
parent | 4f8d9b0db84c42c8d37f75de885de1c0a5cb542c (diff) |
Pattern matching is no longer experimental
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 22 |
1 files changed, 9 insertions, 13 deletions
@@ -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) { |