Project

General

Profile

Actions

Bug #15952

closed

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

Added by luke-gru (Luke Gruber) over 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
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 #2

Updated by luke-gru (Luke Gruber) over 3 years ago

  • Status changed from Open to Closed

Applied in changeset git|ec8e5f5aa64e2a54cf1e303f2b012c98e8d521ba.


array.c: always check frozenness in Array#unshift. Fixes [Bug #15952]

Closes: https://github.com/ruby/ruby/pull/2251

Actions #3

Updated by nagachika (Tomoyuki Chikanaga) over 3 years ago

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

Updated by nagachika (Tomoyuki Chikanaga) about 3 years ago

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

ruby_2_6 r67740 merged revision(s) ec8e5f5aa64e2a54cf1e303f2b012c98e8d521ba,5a187e26adc8aa32367f294c1496935c7356d386.

Updated by usa (Usaku NAKAMURA) about 3 years ago

  • 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.

Actions

Also available in: Atom PDF