Permalink
Browse files

Fix Symbol#to_proc when the returned Proc calling without receiver

  • Loading branch information...
1 parent a9b2866 commit e7ea4128bfa356da49c96566a89e32f109dd6be4 @kachick committed Apr 24, 2013
Showing with 8 additions and 2 deletions.
  1. +4 −1 kernel/common/symbol18.rb
  2. +4 −1 kernel/common/symbol19.rb
@@ -26,6 +26,9 @@ def to_proc
# we leave the symbol in sym and use it in the block.
#
sym = self
- Proc.new { |*args| args.shift.__send__(sym, *args) }
+ Proc.new do |*args|
+ raise ArgumentError, "no receiver given" if args.empty?
+ args.shift.__send__(sym, *args)
+ end
end
end
@@ -113,6 +113,9 @@ def to_proc
# we leave the symbol in sym and use it in the block.
#
sym = self
- Proc.new { |*args, &b| args.shift.__send__(sym, *args, &b) }
+ Proc.new do |*args, &b|
+ raise ArgumentError, "no receiver given" if args.empty?
+ args.shift.__send__(sym, *args, &b)
+ end
end
end

0 comments on commit e7ea412

Please sign in to comment.