Raised when there is an attempt to modify a frozen object.
[1, 2, 3].freeze << 4
raises the exception:
FrozenError: can't modify frozen Array
Construct a new FrozenError exception. If given the receiver parameter may subsequently be examined using the #receiver method.
a = [].freeze raise FrozenError.new("can't modify frozen array", a)
static VALUE
frozen_err_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE mesg, recv;
argc = rb_scan_args(argc, argv, "02", &mesg, &recv);
if (argc > 1) {
argc--;
rb_ivar_set(self, id_recv, recv);
}
rb_call_super(argc, argv);
return self;
}
Return the receiver associated with this NameError exception.
static VALUE
name_err_receiver(VALUE self)
{
VALUE *ptr, recv, mesg;
recv = rb_ivar_lookup(self, id_recv, Qundef);
if (recv != Qundef) return recv;
mesg = rb_attr_get(self, id_mesg);
if (!rb_typeddata_is_kind_of(mesg, &name_err_mesg_data_type)) {
rb_raise(rb_eArgError, "no receiver is available");
}
ptr = DATA_PTR(mesg);
return ptr[NAME_ERR_MESG__RECV];
}