Bug #2468
closedArray expansion inside case/when gives unexpected results
Description
=begin
Given the following script:
arr = [1, 2, 3]
case 2
when 1, 2, 3
puts "2 is in range #{arr.inspect}"
else
puts "2 is out of range #{arr.inspect}"
end
case 2
when *arr # this is the only thing different from the previous statement
puts "2 is in range #{arr.inspect}"
else
puts "2 is out of range #{arr.inspect}"
end
Ruby 1.8.8dev gives me the following output:
$ ruby -v
ruby 1.8.8dev (2009-12-07 revision 26034) [i386-mswin32_90]
$ ruby casebug.rb
2 is in range [1, 2, 3]
2 is out of range [1, 2, 3]
I'd expect the same results other versions give:
$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-mswin32_90]
$ ruby casebug.rb
2 is in range [1, 2, 3]
2 is in range [1, 2, 3]
$ ruby -v
ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mswin32]
$ ruby casebug.rb
2 is in range [1, 2, 3]
2 is in range [1, 2, 3]
=end