[MacRuby] #984: strange scoping error in macirb
#984: strange scoping error in macirb -------------------------------------+-------------------------------------- Reporter: mcowan@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: macirb -------------------------------------+-------------------------------------- i tried some example code in macirb and got a scoping error. when i tried this in regular irb it works fine, and when i run this as a script it works fine. i = 0 for i in 1..8 do puts i end -- Ticket URL: <http://www.macruby.org/trac/ticket/984> MacRuby <http://macruby.org/>
#984: strange scoping error in macirb -------------------------------------+-------------------------------------- Reporter: mcowan@… | Owner: eloy.de.enige@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: macirb -------------------------------------+-------------------------------------- Changes (by lsansonetti@…): * owner: lsansonetti@… => eloy.de.enige@… -- Ticket URL: <http://www.macruby.org/trac/ticket/984#comment:1> MacRuby <http://macruby.org/>
#984: strange scoping error in macirb -------------------------------------+-------------------------------------- Reporter: mcowan@… | Owner: eloy.de.enige@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: macirb -------------------------------------+-------------------------------------- Description changed by eloy.de.enige@…: Old description:
i tried some example code in macirb and got a scoping error. when i tried this in regular irb it works fine, and when i run this as a script it works fine.
i = 0 for i in 1..8 do puts i end
New description: i tried some example code in macirb and got a scoping error. when i tried this in regular irb it works fine, and when i run this as a script it works fine. {{{ i = 0 for i in 1..8 do puts i end }}} -- -- Ticket URL: <http://www.macruby.org/trac/ticket/984#comment:2> MacRuby <http://macruby.org/>
#984: strange scoping error in macirb -------------------------------------+-------------------------------------- Reporter: mcowan@… | Owner: eloy.de.enige@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: macirb -------------------------------------+-------------------------------------- Comment(by eloy.de.enige@…): On MRI 1.9: {{{ $ rake19 (in /Users/eloy/code/DietRB) /usr/local/bin/ruby19 -I lib ./bin/dietrb -d -r irb/ext/colorize -r pp irb(main):001:0> i = 0 => 0 irb(main):002:0> for i in 1..8 do irb(main):003:2> puts i irb(main):004:1> end 1 2 3 4 5 6 7 8 => 1..8 }}} On MacRuby: {{{ $ macrake (in /Users/eloy/code/DietRB) /Library/Frameworks/MacRuby.framework/Versions/0.8/usr/bin/macruby -I lib ./bin/dietrb -d -r irb/ext/colorize -r pp irb(main):001:0> i = 0 => 0 irb(main):002:0> for i in 1..8 do irb(main):003:2> puts i irb(main):004:1> end NameError: undefined local variable or method `i' for main:TopLevel /Users/eloy/code/DietRB/(irb):3:in `block' /Users/eloy/code/DietRB/(irb):2:in `<main>' /Users/eloy/code/DietRB/lib/irb/context.rb:28:in `__evaluate__:' /Users/eloy/code/DietRB/lib/irb/context.rb:39:in `evaluate:' /Users/eloy/code/DietRB/lib/irb/context.rb:74:in `process_line:' /Users/eloy/code/DietRB/lib/irb/driver/tty.rb:47:in `run:' /Users/eloy/code/DietRB/lib/irb/driver/tty.rb:61:in `irb:' /Users/eloy/code/DietRB/./bin/dietrb:55:in `block' /Users/eloy/code/DietRB/./bin/dietrb:9:in `block' /Users/eloy/code/DietRB/./bin/dietrb:7:in `<main>' }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/984#comment:3> MacRuby <http://macruby.org/>
#984: strange scoping error in macirb -------------------------------------+-------------------------------------- Reporter: mcowan@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: eval for-loop -------------------------------------+-------------------------------------- Changes (by eloy.de.enige@…): * keywords: macirb => eval for-loop * owner: eloy.de.enige@… => lsansonetti@… Comment: Works without eval: {{{ $ macruby -e "i = 0; for i in 1..2 do; puts i; end" 1 2 }}} Fails as reported with eval and specific binding: {{{ $ macruby -e "eval('i = 0; for i in 1..2 do; puts i; end', TOPLEVEL_BINDING)" /Users/eloy/code/DietRB/(eval):1:in `block': undefined local variable or method `i' for main:TopLevel (NameError) from /Users/eloy/code/DietRB/(eval):1:in `<main>' from -e:1:in `<main>' }}} Hits an assertion with eval and no specific binding: {{{ $ macruby -e "eval('i = 0; for i in 1..2 do; puts i; end')" Assertion failed: (current_block), function compile_lvar_slot, file compiler.cpp, line 6177. }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/984#comment:4> MacRuby <http://macruby.org/>
#984: strange scoping error in macirb -------------------------------------+-------------------------------------- Reporter: mcowan@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: eval for-loop -------------------------------------+-------------------------------------- Comment(by eloy.de.enige@…): The assertion problem also happens with #each: {{{ $ macruby -e "eval('i = 0; (1..2).each do |i|; puts i; end')" Assertion failed: (current_block), function compile_lvar_slot, file compiler.cpp, line 6177. }}} But not if the outer i lvar that is being shadowed is removed: {{{ $ macruby -e "eval('(1..2).each do |i|; puts i; end')" 1 2 }}} However, the for-loop still bails without the shadowing, although at a different assertion: {{{ $ macruby -e "eval('for i in 1..2 do; puts i; end')" Assertion failed: (slot != NULL), function compile_lvar_slot, file compiler.cpp, line 6179. }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/984#comment:5> MacRuby <http://macruby.org/>
#984: strange scoping error in macirb -------------------------------------+-------------------------------------- Reporter: mcowan@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: MacRuby 0.8 Component: MacRuby | Resolution: fixed Keywords: eval for-loop | -------------------------------------+-------------------------------------- Changes (by lsansonetti@…): * status: new => closed * resolution: => fixed * milestone: => MacRuby 0.8 Comment: Should be fixed in r4876. -- Ticket URL: <http://www.macruby.org/trac/ticket/984#comment:6> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby