ruby-changes:58695
From: Kazuki <ko1@a...>
Date: Sun, 10 Nov 2019 22:39:43 +0900 (JST)
Subject: [ruby-changes:58695] 6e70fa49b1 (master): Disallow omission of parentheses/brackets in single line pattern matching [Feature #16182]
https://git.ruby-lang.org/ruby.git/commit/?id=6e70fa49b1 From 6e70fa49b111e2a2839297b057a3df354cae265a Mon Sep 17 00:00:00 2001 From: Kazuki Tsujimoto <kazuki@c...> Date: Sun, 10 Nov 2019 22:34:49 +0900 Subject: Disallow omission of parentheses/brackets in single line pattern matching [Feature #16182] diff --git a/parse.y b/parse.y index 8b5e1d5..e234392 100644 --- a/parse.y +++ b/parse.y @@ -1569,7 +1569,7 @@ expr : command_call https://github.com/ruby/ruby/blob/trunk/parse.y#L1569 $<tbl>$ = p->pvtbl; p->pvtbl = st_init_numtable(); } - p_top_expr_body + p_expr { st_free_table(p->pvtbl); p->pvtbl = $<tbl>4; diff --git a/test/ruby/test_pattern_matching.rb b/test/ruby/test_pattern_matching.rb index 9af091a..69524cb 100644 --- a/test/ruby/test_pattern_matching.rb +++ b/test/ruby/test_pattern_matching.rb @@ -1261,7 +1261,13 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_pattern_matching.rb#L1261 def test_modifier_in assert_equal true, (1 in a) assert_equal 1, a - assert_valid_syntax "p(({} in a:), a:\n 1)" + assert_valid_syntax "p(({} in {a:}), a:\n 1)" + assert_syntax_error(%q{ + 1 in a, b + }, /unexpected/, '[ruby-core:95098]') + assert_syntax_error(%q{ + 1 in a: + }, /unexpected/, '[ruby-core:95098]') end end END_of_GUARD -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/