1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merge revision(s) 56111: [Backport #12738]

* array.c (flatten): use rb_obj_class instead of rb_class_of
	  because rb_class_of may return a singleton class.
	  [ruby-dev:49781] [Bug #12738]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@56305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2016-09-30 15:54:16 +00:00
parent f0608fca8c
commit 4af941c708
4 changed files with 26 additions and 2 deletions

View file

@ -1,3 +1,9 @@
Sat Oct 1 00:53:28 2016 Kazuki Tsujimoto <kazuki@callcc.net>
* array.c (flatten): use rb_obj_class instead of rb_class_of
because rb_class_of may return a singleton class.
[ruby-dev:49781] [Bug #12738]
Sat Oct 1 00:52:34 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* man/irb.1: remove useless -width option.

View file

@ -4383,7 +4383,7 @@ flatten(VALUE ary, int level, int *modified)
st_free_table(memo);
RBASIC_SET_CLASS(result, rb_class_of(ary));
RBASIC_SET_CLASS(result, rb_obj_class(ary));
return result;
}

View file

@ -784,6 +784,15 @@ class TestArray < Test::Unit::TestCase
assert_not_same(a8, a9)
end
def test_flattern_singleton_class
bug12738 = '[ruby-dev:49781] [Bug #12738]'
a = [[0]]
class << a
def m; end
end
assert_raise(NoMethodError, bug12738) { a.flatten.m }
end
def test_flatten!
a1 = @cls[ 1, 2, 3]
a2 = @cls[ 5, 6 ]
@ -804,6 +813,15 @@ class TestArray < Test::Unit::TestCase
assert_nil(@cls[].flatten!(0), '[ruby-core:23382]')
end
def test_flattern_singleton_class!
bug12738 = '[ruby-dev:49781] [Bug #12738]'
a = [[0]]
class << a
def m; end
end
assert_nothing_raised(NameError, bug12738) { a.flatten!.m }
end
def test_flatten_with_callcc
need_continuation
o = Object.new

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.2.6"
#define RUBY_RELEASE_DATE "2016-10-01"
#define RUBY_PATCHLEVEL 374
#define RUBY_PATCHLEVEL 375
#define RUBY_RELEASE_YEAR 2016
#define RUBY_RELEASE_MONTH 10