[MacRuby] #1056: Module method is bypassed by 'super' statement when more than one modules are extended.

MacRuby ruby-noreply at macosforge.org
Fri Dec 17 17:10:39 PST 2010


#1056: Module method is bypassed by 'super' statement when more than one modules
are extended.
--------------------------------+-------------------------------------------
 Reporter:  chekenan@…          |       Owner:  lsansonetti@…                
     Type:  defect              |      Status:  new                          
 Priority:  blocker             |   Milestone:  MacRuby 0.8                  
Component:  MacRuby             |    Keywords:  module, method, extend, super
--------------------------------+-------------------------------------------
 The summary can't precisely describe the situation causes this bug. Sorry
 for that.

 But the test code can.

 '''Test'''

 {{{

 p RUBY_DESCRIPTION

 module M1
   def m
     p 'm1'
     [1,2,3]
   end
 end

 module M2
   def m
     p 'm2'
     super.select do |item|; item > 1; end
   end
 end

 o = Object.new
 o.extend M1
 o.extend M2

 class Cls
   def m
     p 'cls'
     [1,2,3]
   end
 end

 o1 = Cls.new
 o1.extend M2

 def o.use_m
   p m
 end

 def o1.use_m
   p m
 end

 puts "--- Module over module"

 o.use_m
 o.use_m
 o.use_m

 puts "--- Class over module"

 o1.use_m
 o1.use_m
 o1.use_m

 }}}

 In the second and third runs, method 'm' of module M2 is bypassed.

 This bug prevent Treetop (1.4.9) from running on MacRuby 0.8.

 Note that if super is a class, the module method is not bypassed.

 '''Result'''

 {{{
 "MacRuby 0.8 (ruby 1.9.2) [universal-darwin10.0, x86_64]"
 --- Module over module
 "m2"
 "m1"
 [2, 3]
 "m1"
 [1, 2, 3]
 "m1"
 [1, 2, 3]
 --- Class over module
 "m2"
 "cls"
 [2, 3]
 "m2"
 "cls"
 [2, 3]
 "m2"
 "cls"
 [2, 3]
 "rubinius 1.1.0 (1.8.7 release 2010-09-23 JI) [x86_64-apple-darwin10.4.0]"
 --- Module over module
 "m2"
 "m1"
 [2, 3]
 "m2"
 "m1"
 [2, 3]
 "m2"
 "m1"
 [2, 3]
 --- Class over module
 "m2"
 "cls"
 [2, 3]
 "m2"
 "cls"
 [2, 3]
 "m2"
 "cls"
 [2, 3]
 "ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]"
 --- Module over module
 "m2"
 "m1"
 [2, 3]
 "m2"
 "m1"
 [2, 3]
 "m2"
 "m1"
 [2, 3]
 --- Class over module
 "m2"
 "cls"
 [2, 3]
 "m2"
 "cls"
 [2, 3]
 "m2"
 "cls"
 [2, 3]
 }}}

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



More information about the macruby-tickets mailing list