[MacRuby] #1113: unexpected behaviour with enumerateObjectsUsingBlock
#1113: unexpected behaviour with enumerateObjectsUsingBlock ----------------------------------+----------------------------------------- Reporter: al_skipp@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- If a Proc is defined that uses 'enumerateObjectsUsingBlock' and that proc is then called on all items of an array by iterating through the array with 'enumerateObjectsUsingBlock', the parameters to both blocks are sent to the inner enumeration. Example below. {{{ framework 'Foundation' proc = Proc.new do |arg| [1,2,3].enumerateObjectsUsingBlock( Proc.new { |o, i, s| puts "inner enumeration #{o}" } ) puts arg.upcase end %w[a b c].enumerateObjectsUsingBlock( Proc.new do |obj, idx, stop| proc.call(obj) end ) }}} Output: {{{ inner enumeration 1 inner enumeration 2 inner enumeration 3 A inner enumeration b inner enumeration c }}} Expected output: {{{ inner enumeration 1 inner enumeration 2 inner enumeration 3 A inner enumeration 1 inner enumeration 2 inner enumeration 3 B inner enumeration 1 inner enumeration 2 inner enumeration 3 C }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1113> MacRuby <http://macruby.org/>
#1113: unexpected behaviour with enumerateObjectsUsingBlock ----------------------------------+----------------------------------------- Reporter: al_skipp@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: MacRuby 1.0 Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Changes (by lsansonetti@…): * milestone: => MacRuby 1.0 Comment: The problem is because the calling stub uses a global variable to store the proc and later call it. However, as calling stubs are cached by type, in this condition (messaging the same block method twice) overrides the global variable. This problem must be fixed in 1.0. -- Ticket URL: <http://www.macruby.org/trac/ticket/1113#comment:1> MacRuby <http://macruby.org/>
#1113: unexpected behaviour with enumerateObjectsUsingBlock ----------------------------------+----------------------------------------- Reporter: al_skipp@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: MacRuby 0.9 Component: MacRuby | Resolution: fixed Keywords: | ----------------------------------+----------------------------------------- Changes (by lsansonetti@…): * status: new => closed * resolution: => fixed * milestone: MacRuby 1.0 => MacRuby 0.9 Comment: Should be fixed in r5163. C function pointers will suffer of the same problem, so a separate fix for them will be committed later. -- Ticket URL: <http://www.macruby.org/trac/ticket/1113#comment:2> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby