diff options
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -2290,9 +2290,14 @@ define_final(int argc, VALUE *argv, VALUE os) rb_raise(rb_eArgError, "wrong type argument %s (should be callable)", rb_obj_classname(block)); } - FL_SET(obj, FL_FINALIZE); + if (!FL_ABLE(obj)) { + rb_raise(rb_eArgError, "cannot define finalizer for %s", + rb_obj_classname(obj)); + } + RBASIC(obj)->flags |= FL_FINALIZE; block = rb_ary_new3(2, INT2FIX(rb_safe_level()), block); + OBJ_FREEZE(block); if (!finalizer_table) { finalizer_table = st_init_numtable(); |