Issue #6476 has been reported by prijutme4ty (Ilya Vorontsov).

----------------------------------------
Bug #6476: Proc unrolls an array even without splat
https://bugs.ruby-lang.org/issues/6476

Author: prijutme4ty (Ilya Vorontsov)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: 1.9.3p194


Normal behaviour:

def pr_def(recv,*args)
  puts "#{recv.inspect} + #{args.inspect}"
end
pr_def(*[1,2,3])  # => [1] + [2,3]
pr_def([1,2,3])   # => [1,2,3] + []
pr_def([[1,2,3]]) # => [[1,2,3]] + []

pr_lambda = lambda{|recv,*args| puts "#{recv.inspect} + #{args.inspect}"}
pr_lambda.call(*[1,2,3])  # => [1] + [2,3]
pr_lambda.call([1,2,3])   # => [1,2,3] + []
pr_lambda.call([[1,2,3]]) # => [[1,2,3]] + []


But Proc acts in a different way.

pr_proc = Proc.new{|recv,*args| puts "#{recv.inspect} + #{args.inspect}"}
pr_proc.call(*[1,2,3])   # => 1 + [2,3]
pr_proc.call([1,2,3])    # => 1 + [2,3]
pr_proc.call([[1,2,3]])  # => [1,2,3] + []

Is it right behaviour or such unsplatting is a bug?


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