Backport #1322

define_method scope bug

Added by coderrr . almost 3 years ago. Updated 9 months ago.

[ruby-core:23050]
Status:Assigned Start date:03/29/2009
Priority:High Due date:
Assignee: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 almost 3 years 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

Updated by coderrr . almost 3 years ago

Any reason there have been no responses to this?

Updated by Shyouhei Urabe almost 3 years ago

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

Updated by Nobuyoshi Nakada almost 3 years ago

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

Updated by Shyouhei Urabe over 2 years ago

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

Updated by Shyouhei Urabe over 2 years ago

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

Updated by Kirk Haines about 2 years ago

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

Also available in: Atom PDF