Project

General

Profile

Actions

Bug #15952

closed

Issue with Array#unshift, sometimes doesn't respect frozenness of array

Added by luke-gru (Luke Gruber) almost 5 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:93322]

Description

This should raise a FrozenError, but doesn't:

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,

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0