cannot catch an exception caused by #1680 #1765

Closed
tsahara opened this Issue Feb 28, 2014 · 0 comments

Comments

Projects
None yet
1 participant
@tsahara
Member

tsahara commented Feb 28, 2014

It should be an instance of ArgumentError, but we cannot catch it.

begin
  #1.to_s(2, 3)
  f = Fiber.new do
    "xyz".send(:each_byte) do |c|
      Fiber.yield(c)
    end
  end
  f.resume
rescue ArgumentError => e
  p e.class
rescue Exception => e
  p e.class
ensure
  p "ensure clause"
end
% bin/mruby a.rb
trace:
        [3] a.rb:5:in Object.call
        [2] mrblib/string.rb:122:in String.each_byte
        [0] a.rb:4
a.rb:5: can't cross C function boundary (ArgumentError)

If we remove a comment mark on line 2, rescue and endure statements work as expected.

begin
  1.to_s(2, 3)
  f = Fiber.new do
    "xyz".send(:each_byte) do |c|
      Fiber.yield(c)
    end
  end
  f.resume
rescue ArgumentError => e
  p e.class
rescue Exception => e
  p e.class
ensure
  p "ensure clause"
end
% bin/mruby a.rb
ArgumentError
"ensure clause"

@matz matz closed this in 8e170ce Mar 1, 2014

matz added a commit that referenced this issue Mar 1, 2014

take-cheeze added a commit to take-cheeze/mruby that referenced this issue Mar 1, 2014

cremno added a commit to cremno/mruby that referenced this issue Mar 4, 2014

ghost pushed a commit to iij/mruby that referenced this issue Mar 11, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment