mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Modifying frozen objects will raise FrozenError.
`FrozenError` is a subclass of `RuntimeError` which used to be raised. [Ruby2.5]
This commit is contained in:
+1
-1
@@ -114,7 +114,7 @@ static void
|
||||
ary_modify_check(mrb_state *mrb, struct RArray *a)
|
||||
{
|
||||
if (MRB_FROZEN_P(a)) {
|
||||
mrb_raise(mrb, E_RUNTIME_ERROR, "can't modify frozen array");
|
||||
mrb_raise(mrb, E_FROZEN_ERROR, "can't modify frozen array");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -430,9 +430,9 @@ mrb_define_method_raw(mrb_state *mrb, struct RClass *c, mrb_sym mid, mrb_method_
|
||||
|
||||
if (MRB_FROZEN_P(c)) {
|
||||
if (c->tt == MRB_TT_MODULE)
|
||||
mrb_raise(mrb, E_RUNTIME_ERROR, "can't modify frozen module");
|
||||
mrb_raise(mrb, E_FROZEN_ERROR, "can't modify frozen module");
|
||||
else
|
||||
mrb_raise(mrb, E_RUNTIME_ERROR, "can't modify frozen class");
|
||||
mrb_raise(mrb, E_FROZEN_ERROR, "can't modify frozen class");
|
||||
}
|
||||
if (!h) h = c->mt = kh_init(mt, mrb);
|
||||
k = kh_put(mt, mrb, h, mid);
|
||||
|
||||
+1
-1
@@ -286,7 +286,7 @@ static void
|
||||
mrb_hash_modify(mrb_state *mrb, mrb_value hash)
|
||||
{
|
||||
if (MRB_FROZEN_P(mrb_hash_ptr(hash))) {
|
||||
mrb_raise(mrb, E_RUNTIME_ERROR, "can't modify frozen hash");
|
||||
mrb_raise(mrb, E_FROZEN_ERROR, "can't modify frozen hash");
|
||||
}
|
||||
mrb_hash_tbl(mrb, hash);
|
||||
}
|
||||
|
||||
+1
-1
@@ -494,7 +494,7 @@ static void
|
||||
check_frozen(mrb_state *mrb, struct RString *s)
|
||||
{
|
||||
if (MRB_FROZEN_P(s)) {
|
||||
mrb_raise(mrb, E_RUNTIME_ERROR, "can't modify frozen string");
|
||||
mrb_raise(mrb, E_FROZEN_ERROR, "can't modify frozen string");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -261,7 +261,7 @@ mrb_obj_iv_set(mrb_state *mrb, struct RObject *obj, mrb_sym sym, mrb_value v)
|
||||
iv_tbl *t = obj->iv;
|
||||
|
||||
if (MRB_FROZEN_P(obj)) {
|
||||
mrb_raisef(mrb, E_RUNTIME_ERROR, "can't modify frozen %S", mrb_obj_value(obj));
|
||||
mrb_raisef(mrb, E_FROZEN_ERROR, "can't modify frozen %S", mrb_obj_value(obj));
|
||||
}
|
||||
if (!t) {
|
||||
t = obj->iv = iv_new(mrb);
|
||||
|
||||
Reference in New Issue
Block a user