#305 open
Matijs van Zuijlen

Exception in callcc/throw combination

Reported by Matijs van Zuijlen | February 3rd, 2008 @ 05:36 AM | in 1.0 preview

The following code throws an exception when run with rubinius:

def setcc
  puts "setcc called"
  callcc do|c|
    @c = c
    throw :foo, true
  end
end

result = catch :foo do
  2.times { setcc }
  false
end
@c.call if result

Using MRI 1.8.6, it prints:

setcc called
setcc called

Using rubinius, the result is:

setcc called
setcc called
An exception has occurred:
    Unknown catch label 'foo' (NameError)

Backtrace:
           Kernel(Object)#throw at kernel/core/throw_catch.rb:75
                Object#setcc {} at callcc.rb:5
          Kernel(Object)#callcc at kernel/core/continuation.rb:50
                   Object#setcc at callcc.rb:3
             main.__script__ {} at callcc.rb:10
             main.__script__ {} at callcc.rb:10
        Kernel(Object)#catch {} at kernel/core/throw_catch.rb:61
           ThrownValue.register at kernel/core/throw_catch.rb:46
           Kernel(Object)#catch at kernel/core/throw_catch.rb:65
                main.__script__ at callcc.rb:9
       CompiledMethod#as_script at kernel/core/compiled_method.rb:206
            Compile.single_load at kernel/core/compile.rb:219
    Compile.load_from_extension at kernel/core/compile.rb:291
                main.__script__ at kernel/loader.rb:177

Comments and changes to this ticket

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket