diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-11 13:52:35 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-11 13:52:35 +0000 |
commit | 03ad9a258e6bb82e7351e617bb6c8dbabe142f44 (patch) | |
tree | 14584f77f6099ce55459a1e26b2fe1e09e1ab632 | |
parent | 80f81024c3efa153620de8d0857da0820a09572b (diff) |
merge revision(s) 53039: [Backport #11804]
* insns.def (opt_case_dispatch): avoid converting Infinity
* test/ruby/test_optimization.rb (test_opt_case_dispatch_inf): new
[ruby-dev:49423] [Bug #11804]'
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@53040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | insns.def | 2 | ||||
-rw-r--r-- | test/ruby/test_optimization.rb | 11 | ||||
-rw-r--r-- | version.h | 6 |
4 files changed, 21 insertions, 4 deletions
@@ -1,3 +1,9 @@ +Fri Dec 11 22:41:15 2015 Eric Wong <e@80x24.org> + + * insns.def (opt_case_dispatch): avoid converting Infinity + * test/ruby/test_optimization.rb (test_opt_case_dispatch_inf): new + [ruby-dev:49423] [Bug #11804]' + Thu Dec 10 00:23:07 2015 Rei Odaira <Rei.Odaira@gmail.com> * configure.in: pthread_getattr_np is broken on AIX. @@ -1315,7 +1315,7 @@ opt_case_dispatch switch(TYPE(key)) { case T_FLOAT: { double ival; - if (modf(RFLOAT_VALUE(key), &ival) == 0.0) { + if (modf(RFLOAT_VALUE(key), &ival) == 0.0 && !isinf(ival)) { key = FIXABLE(ival) ? LONG2FIX((long)ival) : rb_dbl2big(ival); } } diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb index 9250f013c4..91b46cc98c 100644 --- a/test/ruby/test_optimization.rb +++ b/test/ruby/test_optimization.rb @@ -330,4 +330,15 @@ class TestRubyOptimization < Test::Unit::TestCase end; end end + + def test_opt_case_dispatch_inf + inf = 1.0/0.0 + result = case inf + when 1 then 1 + when 0 then 0 + else + inf.to_i rescue nil + end + assert_nil result, '[ruby-dev:49423] [Bug #11804]' + end end @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.2.4" -#define RUBY_RELEASE_DATE "2015-12-10" -#define RUBY_PATCHLEVEL 226 +#define RUBY_RELEASE_DATE "2015-12-11" +#define RUBY_PATCHLEVEL 227 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 12 -#define RUBY_RELEASE_DAY 10 +#define RUBY_RELEASE_DAY 11 #include "ruby/version.h" |