Permalink
Browse files

freeze classes/modules; ref #3340

  • Loading branch information...
matz committed Dec 11, 2016
1 parent 761562b commit 1164463a7c21699cfee2e0fb610ae9931b830cc0
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/class.c
View
@@ -370,6 +370,12 @@ mrb_define_method_raw(mrb_state *mrb, struct RClass *c, mrb_sym mid, struct RPro
MRB_CLASS_ORIGIN(c);
h = c->mt;
if (MRB_FROZEN_P(c)) {
if (c->tt == MRB_TT_MODULE)
mrb_raise(mrb, E_RUNTIME_ERROR, "can't modify frozen module");
else
mrb_raise(mrb, E_RUNTIME_ERROR, "can't modify frozen class");
}
if (!h) h = c->mt = kh_init(mt, mrb);
k = kh_put(mt, mrb, h, mid);
kh_value(h, k) = p;

0 comments on commit 1164463

Please sign in to comment.