diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-29 13:53:46 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-29 13:53:46 +0000 |
commit | 337a3da71cd3c7e98d9c11b1f58e53049489dacf (patch) | |
tree | 7205365c8ae82e944f1369c4508f4f608091d7ee | |
parent | 4cfbf8ec95cb321e494a47fe0c82447f2ddbc872 (diff) |
merge revision(s) 53635: [Backport #12003]
* range.c (range_eqq): revert r11113 because rb_call_super() is
called in range_include() and thus r11113 doesn't work when the
receiver Range object consists of non linear objects such as Date
objects.
[ruby-core:72908] [Bug #12003]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@54403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | range.c | 8 | ||||
-rw-r--r-- | test/ruby/test_range.rb | 24 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 34 insertions, 8 deletions
@@ -1,3 +1,11 @@ +Tue Mar 29 22:31:48 2016 Shugo Maeda <shugo@ruby-lang.org> + + * range.c (range_eqq): revert r11113 because rb_call_super() is + called in range_include() and thus r11113 doesn't work when the + receiver Range object consists of non linear objects such as Date + objects. + [ruby-core:72908] [Bug #12003] + Tue Mar 29 22:26:55 2016 Nobuyoshi Nakada <nobu@ruby-lang.org> * vm_eval.c (rb_check_funcall_with_hook): also should call the @@ -23,7 +23,6 @@ static ID id_beg, id_end, id_excl, id_integer_p, id_div; #define id_succ idSucc static VALUE r_cover_p(VALUE, VALUE, VALUE, VALUE); -static VALUE range_include(VALUE range, VALUE val); #define RANGE_BEG(r) (RSTRUCT(r)->as.ary[0]) #define RANGE_END(r) (RSTRUCT(r)->as.ary[1]) @@ -1135,12 +1134,7 @@ range_inspect(VALUE range) static VALUE range_eqq(VALUE range, VALUE val) { - ID pred; - CONST_ID(pred, "include?"); - if (rb_method_basic_definition_p(RBASIC_CLASS(range), pred)) { - return range_include(range, val); - } - return rb_funcall(range, pred, 1, val); + return rb_funcall(range, rb_intern("include?"), 1, val); } diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb index 046f69e9de..2fc2a2b1d3 100644 --- a/test/ruby/test_range.rb +++ b/test/ruby/test_range.rb @@ -314,6 +314,30 @@ class TestRange < Test::Unit::TestCase } end + def test_eqq_non_linear + bug12003 = '[ruby-core:72908] [Bug #12003]' + c = Class.new { + attr_reader :value + + def initialize(value) + @value = value + end + + def succ + self.class.new(@value.succ) + end + + def ==(other) + @value == other.value + end + + def <=>(other) + @value <=> other.value + end + } + assert_operator(c.new(0)..c.new(10), :===, c.new(5), bug12003) + end + def test_include assert_include("a".."z", "c") assert_not_include("a".."z", "5") @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.3.0" #define RUBY_RELEASE_DATE "2016-03-29" -#define RUBY_PATCHLEVEL 51 +#define RUBY_PATCHLEVEL 52 #define RUBY_RELEASE_YEAR 2016 #define RUBY_RELEASE_MONTH 3 |