diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-16 07:11:41 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-16 07:11:41 +0000 |
commit | 703a24a9478e83925e4275d126bb54848a72076b (patch) | |
tree | c70629a744bc27db836d1b1a40d9d190414b3118 | |
parent | 2e1523316d1de17fc80257a601aadac6df452fde (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_1@53147 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 | 2 |
4 files changed, 19 insertions, 2 deletions
@@ -1,3 +1,9 @@ +Wed Dec 16 16:10:52 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]' + Wed Dec 16 16:07:29 2015 Rei Odaira <Rei.Odaira@gmail.com> * configure.in: pthread_getattr_np is broken on AIX. @@ -1275,7 +1275,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 c484dcd0c8..6e22891ddd 100644 --- a/test/ruby/test_optimization.rb +++ b/test/ruby/test_optimization.rb @@ -242,4 +242,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,6 +1,6 @@ #define RUBY_VERSION "2.1.8" #define RUBY_RELEASE_DATE "2015-12-16" -#define RUBY_PATCHLEVEL 436 +#define RUBY_PATCHLEVEL 437 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 12 |