From: nobu.nokada@... Date: 2002-01-08T05:41:54+09:00 Subject: Re: Possible bug with struct.c (Re: Re: Structs and Marshalling) At Tue, 8 Jan 2002 02:36:12 +0900, ts wrote: > One possible solution is to call rb_clear_cache(), when > rb_define_class_xxx() (same for Module) don't create a new class but > return an old one but this is a *BIG MODIFICATION* Another solution is to call rb_clear_cache_by_id() when a method is replaced. Probably, new functions like rb_clear_cache_by_node() and st_swap() might be effective. # I wonder the same problem can occur when any methods are # replaced... Index: eval.c =================================================================== RCS file: /cvs/ruby/src/ruby/eval.c,v retrieving revision 1.238 diff -u -2 -p -r1.238 eval.c --- eval.c 2002/01/04 14:14:34 1.238 +++ eval.c 2002/01/07 19:25:54 @@ -230,5 +230,6 @@ rb_add_method(klass, mid, node, noex) if (OBJ_FROZEN(klass)) rb_error_frozen("class/module"); body = NEW_METHOD(node, noex); - st_insert(RCLASS(klass)->m_tbl, mid, body); + if (st_insert(RCLASS(klass)->m_tbl, mid, body)) + rb_clear_cache_by_id(mid); } -- Nobu Nakada