ruby-changes:56895
From: nagachika <ko1@a...>
Date: Fri, 9 Aug 2019 23:28:26 +0900 (JST)
Subject: [ruby-changes:56895] nagachika: e68627da98 (ruby_2_6): merge revision(s) ec8e5f5aa64e2a54cf1e303f2b012c98e8d521ba,5a187e26adc8aa32367f294c1496935c7356d386: [Backport #15952]
https://git.ruby-lang.org/ruby.git/commit/?id=e68627da98 From e68627da985d118be573cd9f7e30617cb2bd76fc Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> Date: Fri, 9 Aug 2019 14:28:00 +0000 Subject: merge revision(s) ec8e5f5aa64e2a54cf1e303f2b012c98e8d521ba,5a187e26adc8aa32367f294c1496935c7356d386: [Backport #15952] array.c: always check frozenness in Array#unshift. Fixes [Bug #15952] Closes: https://github.com/ruby/ruby/pull/2251 array.c add back shared array optimization to ary_ensure_room_for_unshift Bug fix in commit ec8e5f5aa64e2a [Bug #15952] disabled an optimization in this function. Closes: https://github.com/ruby/ruby/pull/2252 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e diff --git a/array.c b/array.c index 7b92bfe..ec6f232 100644 --- a/array.c +++ b/array.c @@ -1368,6 +1368,7 @@ ary_ensure_room_for_unshift(VALUE ary, int argc) https://github.com/ruby/ruby/blob/trunk/array.c#L1368 VALUE shared = ARY_SHARED(ary); capa = RARRAY_LEN(shared); if (ARY_SHARED_OCCUPIED(shared) && capa > new_len) { + rb_ary_modify_check(ary); head = RARRAY_CONST_PTR_TRANSIENT(ary); sharedp = RARRAY_CONST_PTR_TRANSIENT(shared); goto makeroom_if_need; diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 94ffa73..8d48b86 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1934,6 +1934,17 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_array.rb#L1934 assert_equal(@cls[@cls[1,2], nil, 'dog', 'cat'], a.unshift(@cls[1, 2])) end + def test_unshift_frozen + bug15952 = '[Bug #15952]' + assert_raise(FrozenError, bug15952) do + a = [1] * 100 + b = a[4..-1] + a.replace([1]) + b.freeze + b.unshift("a") + end + end + def test_OR # '|' assert_equal(@cls[], @cls[] | @cls[]) assert_equal(@cls[1], @cls[1] | @cls[]) diff --git a/version.h b/version.h index 4059e38..f043008 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L1 #define RUBY_VERSION "2.6.3" #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 90 +#define RUBY_PATCHLEVEL 91 #define RUBY_RELEASE_YEAR 2019 #define RUBY_RELEASE_MONTH 8 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/