Issue #15952 has been updated by usa (Usaku NAKAMURA).

Backport changed from 2.4: UNKNOWN, 2.5: REQUIRED, 2.6: DONE to 2.4: UNKNOWN, 2.5: DONE, 2.6: DONE

ruby_2_5 r67771 merged revision(s) ec8e5f5aa64e2a54cf1e303f2b012c98e8d521ba,5a187e26adc8aa32367f294c1496935c7356d386.

----------------------------------------
Bug #15952: Issue with Array#unshift, sometimes doesn't respect frozenness of array
https://bugs.ruby-lang.org/issues/15952#change-81038

* Author: luke-gru (Luke Gruber)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.4: UNKNOWN, 2.5: DONE, 2.6: DONE
----------------------------------------
This should raise a `FrozenError`, but doesn't:

```ruby
a = [1] * 100
b = a[4..-1]
a.replace([1])
b.freeze
b.unshift("a") # no error
```

There is a code path in `ary_ensure_room_for_unshift` where the frozen check is skipped. I'll hoist this check to the top of the function in a PR.

Thanks,



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>