summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--insns.def1
-rw-r--r--test/ruby/test_optimization.rb41
-rw-r--r--version.h2
4 files changed, 49 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index a783157bd0..1f82ad1783 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Dec 9 01:49:13 2015 Eric Wong <e@80x24.org>
+
+ * insns.def (opt_case_dispatch): check Float#=== redefinition
+ * test/ruby/test_optimization.rb (test_opt_case_dispatch): new
+ [ruby-core:71920] [Bug #11784]
+
Wed Dec 9 01:46:23 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ruby_atomic.h (ATOMIC_SIZE_CAS): fix the argument order of
diff --git a/insns.def b/insns.def
index 57b53cf549..999dc799c5 100644
--- a/insns.def
+++ b/insns.def
@@ -1326,6 +1326,7 @@ opt_case_dispatch
if (BASIC_OP_UNREDEFINED_P(BOP_EQQ,
SYMBOL_REDEFINED_OP_FLAG |
FIXNUM_REDEFINED_OP_FLAG |
+ FLOAT_REDEFINED_OP_FLAG |
BIGNUM_REDEFINED_OP_FLAG |
STRING_REDEFINED_OP_FLAG)) {
st_data_t val;
diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb
index 4a5484e43d..9250f013c4 100644
--- a/test/ruby/test_optimization.rb
+++ b/test/ruby/test_optimization.rb
@@ -289,4 +289,45 @@ class TestRubyOptimization < Test::Unit::TestCase
assert_equal(false, "block".freeze)
end;
end
+
+ def test_opt_case_dispatch
+ code = <<-EOF
+ case foo
+ when "foo" then :foo
+ when :sym then :sym
+ when 6 then :fix
+ when 0.1 then :float
+ when 0xffffffffffffffff then :big
+ else
+ :nomatch
+ end
+ EOF
+ check = {
+ 'foo' => :foo,
+ :sym => :sym,
+ 6 => :fix,
+ 0.1 => :float,
+ 0xffffffffffffffff => :big,
+ }
+ iseq = RubyVM::InstructionSequence.compile(code)
+ assert_match %r{\bopt_case_dispatch\b}, iseq.disasm
+ check.each do |foo, expect|
+ assert_equal expect, eval("foo = #{foo.inspect}\n#{code}")
+ end
+ assert_equal :nomatch, eval("foo = :blah\n#{code}")
+ check.each do |foo, _|
+ klass = foo.class.to_s
+ assert_separately([], <<-"end;") # do
+ class #{klass}
+ undef ===
+ def ===(*args)
+ false
+ end
+ end
+ foo = #{foo.inspect}
+ ret = #{code}
+ assert_equal :nomatch, ret, foo.inspect
+ end;
+ end
+ end
end
diff --git a/version.h b/version.h
index 8ec7e0a955..26803ab0c0 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.2.4"
#define RUBY_RELEASE_DATE "2015-12-09"
-#define RUBY_PATCHLEVEL 223
+#define RUBY_PATCHLEVEL 224
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 12