pub(crate) enum ArrOp {
Push(usize),
Pop,
Shift,
Unshift(usize),
Splice(usize, usize, usize),
Fill(usize, usize),
CopyWithin(usize, usize),
Reverse,
Sort,
}Expand description
配列の「書き換えを拒む状態」の検査。【2026-11-19】
Array.prototype の書き込み系メソッド(push・pop・shift・unshift・splice・fill・copyWithin・reverse・sort)は、
仕様上 Set(O, P, V, true) / DeletePropertyOrThrow を使うので、Object.freeze 済み・length が
書き換え不可・拡張不可の配列では strict / sloppy を問わず TypeError になる
(ECMA-262 §23.1.3.* の各アルゴリズム、§7.3.4 Set の Throw=true、§7.3.10 DeletePropertyOrThrow、
§10.1.9.2 OrdinarySetWithOwnDescriptor、§10.4.2.4 ArraySetLength)。
以前はフラグを見ずに中身を直接書き換えており、凍結した配列に push できていた。
実装は「先に全部検査してから書く」形(仕様は途中まで書いてから投げる。途中経過の差は
例外を捕まえた後の配列の中身にだけ出る)。何も掛かっていない配列は一度の借用で素通りする。
Variants§
Push(usize)
Pop
Shift
Unshift(usize)
Splice(usize, usize, usize)
先頭の位置・取り除く数・差し込む数
Fill(usize, usize)
CopyWithin(usize, usize)
書き込み先の先頭・個数
Reverse
Sort
Auto Trait Implementations§
impl Freeze for ArrOp
impl RefUnwindSafe for ArrOp
impl Send for ArrOp
impl Sync for ArrOp
impl Unpin for ArrOp
impl UnsafeUnpin for ArrOp
impl UnwindSafe for ArrOp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more