ruby-changes:49595
From: mame <ko1@a...>
Date: Tue, 9 Jan 2018 14:19:24 +0900 (JST)
Subject: [ruby-changes:49595] mame:r61710 (trunk): Allow `-> do rescue; end` as well as `proc do rescue; end`
mame 2018-01-09 14:19:18 +0900 (Tue, 09 Jan 2018) New Revision: 61710 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61710 Log: Allow `-> do rescue; end` as well as `proc do rescue; end` https://twitter.com/takiuchi/status/950593389963051008 Modified files: trunk/parse.y trunk/test/ruby/test_syntax.rb Index: test/ruby/test_syntax.rb =================================================================== --- test/ruby/test_syntax.rb (revision 61709) +++ test/ruby/test_syntax.rb (revision 61710) @@ -1128,6 +1128,24 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L1128 assert_equal(:begin, result) end + def test_rescue_do_end_ensure_in_lambda + result = [] + eval("#{<<-"begin;"}\n#{<<-"end;"}") + begin; + -> do + result << :begin + raise "An exception occurred!" + rescue + result << :rescue + else + result << :else + ensure + result << :ensure + end.call + end; + assert_equal([:begin, :rescue, :ensure], result) + end + def test_return_in_loop obj = Object.new def obj.test Index: parse.y =================================================================== --- parse.y (revision 61709) +++ parse.y (revision 61710) @@ -3453,7 +3453,7 @@ lambda_body : tLAMBEG compstmt '}' https://github.com/ruby/ruby/blob/trunk/parse.y#L3453 token_info_pop("}"); $$ = $2; } - | keyword_do_LAMBDA compstmt k_end + | keyword_do_LAMBDA bodystmt k_end { $$ = $2; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/