зеркало из https://github.com/github/ruby.git
Allow `-> do rescue; end` as well as `proc do rescue; end`
https://twitter.com/takiuchi/status/950593389963051008 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
3a38b3c5d1
Коммит
3cfa84d562
2
parse.y
2
parse.y
|
@ -3453,7 +3453,7 @@ lambda_body : tLAMBEG compstmt '}'
|
|||
token_info_pop("}");
|
||||
$$ = $2;
|
||||
}
|
||||
| keyword_do_LAMBDA compstmt k_end
|
||||
| keyword_do_LAMBDA bodystmt k_end
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
|
|
|
@ -1128,6 +1128,24 @@ eom
|
|||
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче