From: Jeremy Kemper Date: 2010-01-03T20:04:30+09:00 Subject: [ruby-core:27378] [Bug #2551] case/when matches literal *[1,2,3] but not variable *ary Bug #2551: case/when matches literal *[1,2,3] but not variable *ary http://redmine.ruby-lang.org/issues/show/2551 Author: Jeremy Kemper Status: Open, Priority: High Category: core, Target version: Ruby 1.8.8 ruby -v: ruby 1.8.8dev (2010-01-01 revision 26212) [i386-darwin10.2.0] Matching a splat works with a literal but not a variable: $ irb188 >> case 42; when *[41..43]; true end => true >> a = [41..43] => [41..43] >> case 42; when *a; true end => nil Behaves correctly on 1.9.2dev and 1.8.7: $ irb192 >> RUBY_DESCRIPTION => "ruby 1.9.2dev (2010-01-03 trunk 26233) [x86_64-darwin10.2.0]" >> case 42; when *[41..43]; true end => true >> a = [41..43] => [41..43] >> case 42; when *a; true end => true This breaks a lot of code, such as the Builder library which escapes all values as '***' on 1.8.8dev. A test case: diff --git a/test/ruby/test_case.rb b/test/ruby/test_case.rb index af925d1..f996ed6 100644 --- a/test/ruby/test_case.rb +++ b/test/ruby/test_case.rb @@ -52,5 +52,13 @@ class TestCase < Test::Unit::TestCase else assert(false) end + + range = [41..43] + case 42 + when *range + assert(true) + else + assert(false) + end end end ---------------------------------------- http://redmine.ruby-lang.org