[前][次][番号順一覧][スレッド一覧]

ruby-changes:66819

From: Kazuki <ko1@a...>
Date: Sat, 17 Jul 2021 11:16:39 +0900 (JST)
Subject: [ruby-changes:66819] eed5e8f796 (master): One-line pattern matching is no longer experimental

https://git.ruby-lang.org/ruby.git/commit/?id=eed5e8f796

From eed5e8f796ab18e2e0a436dab83e35504ae3ded0 Mon Sep 17 00:00:00 2001
From: Kazuki Tsujimoto <kazuki@c...>
Date: Sat, 17 Jul 2021 11:13:52 +0900
Subject: One-line pattern matching is no longer experimental

https://github.com/ruby/dev-meeting-log/blob/master/DevelopersMeeting20210715Japan.md#feature-17724-make-the-pin-operator-support-instanceclassglobal-variables-jeremyevans0
---
 NEWS.md                            |  2 ++
 doc/syntax/pattern_matching.rdoc   |  2 +-
 parse.y                            | 14 --------------
 test/ruby/test_pattern_matching.rb |  2 --
 4 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index 793da5b..1027dbc 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -23,6 +23,8 @@ Note that each entry is kept to a minimum, see links for details. https://github.com/ruby/ruby/blob/trunk/NEWS.md#L23
     #=> [3, 5]
     ```
 
+* One-line pattern matching is no longer experimental.
+
 * Multiple assignment evaluation order has been made consistent with
   single assignment evaluation order.  With single assignment, Ruby
   uses a left-to-right evaluation order.  With this code:
diff --git a/doc/syntax/pattern_matching.rdoc b/doc/syntax/pattern_matching.rdoc
index 49835de..f80703d 100644
--- a/doc/syntax/pattern_matching.rdoc
+++ b/doc/syntax/pattern_matching.rdoc
@@ -441,7 +441,7 @@ Additionally, when matching custom classes, the expected class can be specified https://github.com/ruby/ruby/blob/trunk/doc/syntax/pattern_matching.rdoc#L441
 
 == Current feature status
 
-As of Ruby 3.0, one-line pattern matching and find patterns are considered _experimental_: its syntax can change in the future. Every time you use these features in code, a warning will be printed:
+As of Ruby 3.1, find patterns are considered _experimental_: its syntax can change in the future. Every time you use these features in code, a warning will be printed:
 
   [0] => [*, 0, *]
   # warning: Find pattern is experimental, and the behavior may change in future versions of Ruby!
diff --git a/parse.y b/parse.y
index dec4b7d..0bea812 100644
--- a/parse.y
+++ b/parse.y
@@ -523,7 +523,6 @@ static NODE *new_find_pattern(struct parser_params *p, NODE *constant, NODE *fnd https://github.com/ruby/ruby/blob/trunk/parse.y#L523
 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 void warn_one_line_pattern_matching(struct parser_params *p, NODE *node, NODE *pattern, bool right_assign);
 
 static NODE *new_kw_arg(struct parser_params *p, NODE *k, const YYLTYPE *loc);
 static NODE *args_with_numbered(struct parser_params*,NODE*,int);
@@ -1739,7 +1738,6 @@ expr		: command_call https://github.com/ruby/ruby/blob/trunk/parse.y#L1738
 			p->ctxt.in_kwarg = $<ctxt>3.in_kwarg;
 		    /*%%%*/
 			$$ = NEW_CASE3($1, NEW_IN($5, 0, 0, &@5), &@$);
-			warn_one_line_pattern_matching(p, $$, $5, true);
 		    /*% %*/
 		    /*% ripper: case!($1, in!($5, Qnil, Qnil)) %*/
 		    }
@@ -1758,7 +1756,6 @@ expr		: command_call https://github.com/ruby/ruby/blob/trunk/parse.y#L1756
 			p->ctxt.in_kwarg = $<ctxt>3.in_kwarg;
 		    /*%%%*/
 			$$ = NEW_CASE3($1, NEW_IN($5, NEW_TRUE(&@5), NEW_FALSE(&@5), &@5), &@$);
-			warn_one_line_pattern_matching(p, $$, $5, false);
 		    /*% %*/
 		    /*% ripper: case!($1, in!($5, Qnil, Qnil)) %*/
 		    }
@@ -12152,17 +12149,6 @@ new_hash_pattern_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, co https://github.com/ruby/ruby/blob/trunk/parse.y#L12149
     return node;
 }
 
-static void
-warn_one_line_pattern_matching(struct parser_params *p, NODE *node, NODE *pattern, bool right_assign)
-{
-    enum node_type type;
-    type = nd_type(pattern);
-
-    if (rb_warning_category_enabled_p(RB_WARN_CATEGORY_EXPERIMENTAL) &&
-	!(right_assign && (type == NODE_LASGN || type == NODE_DASGN || type == NODE_DASGN_CURR)))
-	rb_warn0L_experimental(nd_line(node), "One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!");
-}
-
 static NODE*
 dsym_node(struct parser_params *p, NODE *node, const YYLTYPE *loc)
 {
diff --git a/test/ruby/test_pattern_matching.rb b/test/ruby/test_pattern_matching.rb
index 320c2c0..2fdad78 100644
--- a/test/ruby/test_pattern_matching.rb
+++ b/test/ruby/test_pattern_matching.rb
@@ -1545,8 +1545,6 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_pattern_matching.rb#L1545
 
   def test_experimental_warning
     assert_experimental_warning("case [0]; in [*, 0, *]; end")
-    assert_experimental_warning("0 => 0")
-    assert_experimental_warning("0 in a")
   end
 end
 END_of_GUARD
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]