[MacRuby-devel] [MacRuby] #801: The eval is broken when calls eval with Class/Proc's binding.

MacRuby ruby-noreply at macosforge.org
Sat Jul 17 08:07:48 PDT 2010


#801: The eval is broken when calls eval with Class/Proc's binding.
----------------------------------+-----------------------------------------
 Reporter:  watson1978@…          |       Owner:  lsansonetti@…        
     Type:  defect                |      Status:  new                  
 Priority:  blocker               |   Milestone:                       
Component:  MacRuby               |    Keywords:                       
----------------------------------+-----------------------------------------
 Test Script:
 {{{
 #!ruby
 $ cat test_eval_1.rb
 p "** 1"
 a1 = :ng
 def m
   a1 = :ok
   $b1 = binding
 end
 m
 p eval('a1', $b1)

 #----------
 p "** 2"
 b = proc{
   a2 = :ok
   binding
 }.call
 a2 = :ng
 p eval('a2', b)

 #----------
 p "** 3"
 INFO = :ng
 class C1
   INFO = :ok
   def m
     binding
   end
 end
 p eval('INFO', C1.new.m)

 #----------
 p "** 4"
 class C2
   $b2 = binding
 end

 eval(%q{
   def m
     :ok
   end
 }, $b2)
 p C2.new.m
 }}}

 Result of Ruby 1.9.1:
 {{{
 $ ruby test_eval_1.rb
 "** 1"
 :ok
 "** 2"
 :ok
 "** 3"
 :ok
 "** 4"
 :ok
 }}}

 Result of MacRuby Trunk:
 {{{
 $ macruby test_eval_1.rb
 "** 1"
 :ok
 "** 2"
 :ng
 "** 3"
 :ng
 "** 4"
 /Users/watson/test/ruby/macruby/test_eval_1.rb:1:in `<main>': private
 method `m' called for #<C2:0x2000c69a0> (NoMethodError)
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/801>
MacRuby <http://macruby.org/>



More information about the MacRuby-devel mailing list