Backport #1322 [ruby-core:23050]

define_method scope bug

Added by coderrr . 356 days ago. Updated 100 days ago.

Status :Assigned Start :03/29/2009
Priority :High Due date :
Assigned to :Kirk Haines % Done :

0%

Category :-
Target version :-

Description

a = 1  
 Object.send :define_method, :x do  
   lambda do
     p a
     a = 2  
     p a
   end.call  
 end  
 x(nil)
 p a

output is 1,2,1 instead of 1,2,2

details and possible fix:  http://coderrr.wordpress.com/2009/03/29/ruby-18-define_method-scope-bug/

Associated revisions

Revision 23257
Added by nobu 332 days ago

  • eval.c (proc_invoke): shares dmethod scope local variables. a patch from coderrr at [ruby-core:23050]
  • gc.c (obj_free): do not free cloned scope local variables.

History

04/16/2009 01:10 AM - coderrr .

Any reason there have been no responses to this?

04/16/2009 01:55 AM - Shyouhei Urabe

  • Assigned to set to Yukihiro Matsumoto
No, just beacuse no wan had time to look into your patch.  Sorry.  The situation is confirmed on my machine.

04/22/2009 12:27 PM - Nobuyoshi Nakada

  • Status changed from Open to Closed
  • % Done changed from 0 to 100
Applied in changeset r23257.

05/12/2009 09:57 PM - Shyouhei Urabe

  • Status changed from Closed to Open
  • Assigned to changed from Yukihiro Matsumoto to Shyouhei Urabe

07/09/2009 06:06 PM - Shyouhei Urabe

  • Assigned to changed from Shyouhei Urabe to Kirk Haines
  • Priority changed from Normal to High

12/10/2009 05:21 AM - Kirk Haines

  • Status changed from Open to Assigned
  • % Done changed from 100 to 0

Also available in: Atom PDF