Skip to content

Commit

Permalink
freeze instance variables; ref #3340
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Dec 11, 2016
1 parent 92c843d commit 761562b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/variable.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ 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));
}
if (!t) {
t = obj->iv = iv_new(mrb);
}
Expand Down

0 comments on commit 761562b

Please sign in to comment.