Project

General

Profile

Actions

Bug #22529

closed

Array#fill should respect frozenness from yields

Bug #22529: Array#fill should respect frozenness from yields
1

Added by tenderlovemaking (Aaron Patterson) 9 days ago. Updated 6 days ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 4.0.9 (2026-10-23 revision 3e93b23afc) +PRISM [arm64-darwin25]
[ruby-core:127395]

Description

Array#fill yields to a block, and the array could get frozen in the block, so we need to check for it.

I expect the following program to raise an exception, but instead the array is mutated:

a = [1, 2, 3]
a.fill { a.freeze; 9 }
p a
Actions

Also available in: PDF Atom