[#88240] [Ruby trunk Feature#14759] [PATCH] set M_ARENA_MAX for glibc malloc — sam.saffron@...
Issue #14759 has been updated by sam.saffron (Sam Saffron).
[#88251] Re: [ruby-alerts:8236] failure alert on trunk@P895 (NG (r64134)) — Eric Wong <normalperson@...>
ko1c-failure@atdot.net wrote:
[#88305] [Ruby trunk Bug#14968] [PATCH] io.c: make all pipes nonblocking by default — normalperson@...
Issue #14968 has been reported by normalperson (Eric Wong).
[#88331] [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — samuel@...
Issue #13618 has been updated by ioquatix (Samuel Williams).
[#88342] [Ruby trunk Feature#14955] [PATCH] gc.c: use MADV_FREE to release most of the heap page body — ko1@...
Issue #14955 has been updated by ko1 (Koichi Sasada).
[#88433] [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — ko1@...
Issue #13618 has been updated by ko1 (Koichi Sasada).
ko1@atdot.net wrote:
[#88475] [Ruby trunk Misc#14937] [PATCH] thread_pthread: lazy-spawn timer-thread only on contention — ko1@...
Issue #14937 has been updated by ko1 (Koichi Sasada).
[#88491] Re: [ruby-cvs:71466] k0kubun:r64374 (trunk): test_function.rb: skip running test — Eric Wong <normalperson@...>
k0kubun@ruby-lang.org wrote:
I see. Please remove the test if the test is unnecessary.
Takashi Kokubun <takashikkbn@gmail.com> wrote:
[#88523] [Ruby trunk Bug#14999] ConditionVariable doesn't reacquire the Mutex if Thread#kill-ed — eregontp@...
Issue #14999 has been updated by Eregon (Benoit Daloze).
eregontp@gmail.com wrote:
[#88549] [Ruby trunk Bug#14999] ConditionVariable doesn't reacquire the Mutex if Thread#kill-ed — eregontp@...
Issue #14999 has been updated by Eregon (Benoit Daloze).
[#88676] [Ruby trunk Misc#15014] thread.c: use rb_hrtime_scalar for high-resolution time operations — ko1@...
Issue #15014 has been updated by ko1 (Koichi Sasada).
ko1@atdot.net wrote:
On 2018/08/27 16:16, Eric Wong wrote:
[#88716] Re: [ruby-dev:43715] [Ruby 1.9 - Bug #595] Fiber ignores ensure clause — Eric Wong <normalperson@...>
Koichi Sasada wrote:
[#88723] [Ruby trunk Bug#15041] [PATCH] cont.c: set th->root_fiber to current fiber at fork — ko1@...
Issue #15041 has been updated by ko1 (Koichi Sasada).
[#88767] [Ruby trunk Bug#15050] GC after forking with fibers crashes — ko1@...
Issue #15050 has been updated by ko1 (Koichi Sasada).
Koichi Sasada <ko1@atdot.net> wrote:
[#88774] Re: [ruby-alerts:8955] failure alert on trunk@P895 (NG (r64594)) — Eric Wong <normalperson@...>
ko1c-failure@atdot.net wrote:
[ruby-core:88398] [Ruby trunk Feature#12906] do/end blocks work with ensure/rescue/else
Issue #12906 has been updated by lukenlow (lukenlow lukenlow).
Great work! I'm glad that I found your site and found your help here, this is a very useful help for me http://19216811-admin.com/ 192.168.1.1
----------------------------------------
Feature #12906: do/end blocks work with ensure/rescue/else
https://bugs.ruby-lang.org/issues/12906#change-73451
* Author: josh.cheek (Josh Cheek)
* Status: Closed
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version: 2.5
----------------------------------------
When you want to rescue in a block, you must do this:
~~~ruby
lambda do
begin
raise 'err'
rescue
$! # => #<RuntimeError: err>
end
end.call
~~~
I've wished on numerous occasions that I could omit the begin/end and not need the extra wrapper:
~~~ruby
lambda do
raise 'err'
rescue
$! # => #<RuntimeError: err>
end.call
~~~
This would be consistent with how classes and methods work:
~~~ruby
class C
raise 'err'
rescue
$! # => #<RuntimeError: err>
end
send def m
raise 'err'
rescue
$! # => #<RuntimeError: err>
end
~~~
It's not really clear to me how to submit this since it may require some discussion, but this is the diff:
~~~diff
diff --git a/parse.y b/parse.y
index 54ccc52..223e5d3 100644
--- a/parse.y
+++ b/parse.y
@@ -3757,7 +3757,7 @@ brace_body : {$<vars>$ = dyna_push();}
do_body : {$<vars>$ = dyna_push();}
{$<val>$ = cmdarg_stack >> 1; CMDARG_SET(0);}
- opt_block_param compstmt
+ opt_block_param bodystmt
{
$$ = new_do_body($3, $4);
dyna_pop($<vars>1);
~~~
I added tests for ensure to rubyspec, but there wasn't an obvious place to talk about rescue/else in this context (the spec for rescue only uses it in a begin/end block) It's probably fine as the spec for ensure does hit rescue, too, and they ultimately delegate to the same pieces. Not totally clear, though. I can do more with that if you need.
~~~diff
diff --git a/language/ensure_spec.rb b/language/ensure_spec.rb
index 13575fc..b14b0b5 100644
--- a/language/ensure_spec.rb
+++ b/language/ensure_spec.rb
@@ -124,3 +124,74 @@ describe "An ensure block inside a method" do
@obj.explicit_return_in_method_with_ensure.should == :ensure
end
end
+
+describe "An ensure block inside a do block" do
+ before :each do
+ ScratchPad.record []
+ end
+
+ it "is executed when an exception is raised in it's corresponding do block" do
+ begin
+ lambda do
+ ScratchPad << :begin
+ raise "An exception occured!"
+ ensure
+ ScratchPad << :ensure
+ end.should raise_error(RuntimeError)
+
+ ScratchPad.recorded.should == [:begin, :ensure]
+ end
+ end
+
+ it "is executed when an exception is raised and rescued in it's corresponding do block" do
+ begin
+ lambda do
+ ScratchPad << :begin
+ raise "An exception occured!"
+ rescue
+ ScratchPad << :rescue
+ ensure
+ ScratchPad << :ensure
+ end.call
+
+ ScratchPad.recorded.should == [:begin, :rescue, :ensure]
+ end
+ end
+
+ it "is executed even when a symbol is thrown in it's corresponding do block" do
+ begin
+ catch(:symbol) do
+ lambda do
+ ScratchPad << :begin
+ throw(:symbol)
+ rescue
+ ScratchPad << :rescue
+ ensure
+ ScratchPad << :ensure
+ end.call
+ end
+
+ ScratchPad.recorded.should == [:begin, :ensure]
+ end
+ end
+
+ it "is executed when nothing is raised or thrown in it's corresponding do block" do
+ lambda do
+ ScratchPad << :begin
+ rescue
+ ScratchPad << :rescue
+ ensure
+ ScratchPad << :ensure
+ end.call
+
+ ScratchPad.recorded.should == [:begin, :ensure]
+ end
+
+ it "has no return value" do
+ lambda do
+ :begin
+ ensure
+ :ensure
+ end.call.should == :begin
+ end
+end
~~~
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>