Bug #12809

passing a proc to Kernel#lambda does not create a lambda

Added by sylvain.joyeux (Sylvain Joyeux) about 4 years ago. Updated almost 4 years ago.

Target version:
ruby -v:
2.0.0-p643, 2.1.9, 2.2.5, 2.3.1p112, 2.4.0preview2


I would expect the following:

p = proc { |a| a * 2 }
l = lambda(&p)
puts l.lambda? # => true, 2) # => ArgumentError

But it does not, basically l there looks very much like a non-lambda proc (another test is that a return in p would cause to raise LocalJumpError)


Updated by shyouhei (Shyouhei Urabe) almost 4 years ago

  • Assignee set to akr (Akira Tanaka)
  • Status changed from Open to Assigned

Updated by akr (Akira Tanaka) almost 4 years ago

  • Status changed from Assigned to Rejected

Current behavior is intentional design.

If "lambda" change the lambda-ness of the given block,
the author of "proc { |a| a * 2 }" can not know how the block is interpreted.
This is what the design try to avoid.

Rather, it may be possible to raise error on "lambda" with non-lambda proc object.
This is different issue, though.

Also available in: Atom PDF