Bug #791: Fiber using a Proc object with a parameter having default value doesn't work
http://redmine.ruby-lang.org/issues/show/791

Author: Florian Gilcher
Status: Open, Priority: Normal
Category: core

If you pass a Proc with a default value on a parameter into a Fiber, the default value is ignored.

Example by Wolfgang NĂ¡dasi-Donner:

irb(main):001:0> p = ->(i=4){i+5}
=> #<Proc:0xe8a370@(irb):1 (lambda)>
irb(main):002:0> p[]
=> 9
irb(main):003:0> Fiber.new(&p).resume
NoMethodError: undefined method `+' for nil:NilClass
         from (irb):1:in `block (3 levels) in irb_binding'


A more useful example is...

irb(main):001:0> f = Fiber.new(&(->(i=5){loop{Fiber.yield i+=1}}))
=> #<Fiber:0xe860f8>
irb(main):002:0> f.resume
NoMethodError: undefined method `+' for nil:NilClass
         from (irb):1:in `block (4 levels) in irb_binding'
         from (irb):1:in `loop'
         from (irb):1:in `block (3 levels) in irb_binding'

Regards,
Florian Gilcher


----------------------------------------
http://redmine.ruby-lang.org