Proc looses context #218

Open
niccokunzmann opened this Issue Jan 23, 2013 · 0 comments

Comments

Projects
None yet
1 participant
Contributor

niccokunzmann commented Jan 23, 2013

Hello,

I encountered the following, unexpected behavior:
The context where the Proc is created gets lost and when the Proc is called, it uses the varaibles from where Proc.call was done.

This is irb 1.9 and my expected:

x = Object.new # create context
p = x.instance_eval 'l = [];Proc.new{l<< 3;l}' # create proc in this context
=> #< Proc:0x00000002bf0ac0@(eval):1 >
p.call # call the proc
=> [3]

This is MagLev, branch hpi & master

l = StandardError
x = Object.new
p = x.instance_eval 'l = [];Proc.new{l<< 3;l}'
=> #< Proc >
p.call
NoMethodError: NoMethodError: undefined method <<' for StandardError:Class from (eval) from line 2 of <eval>:3:in__compileEval'
from /home/Documents/maglev/HPI-GSS-BuildEnv/git/src/kernel/bootstrap/Proc.rb:331:in call' from (irb):5:in__compileEval'
from (irb):7:in __compileEval' from /home/Documents/maglev/HPI-GSS-BuildEnv/git/src/kernel/bootstrap/Kernel.rb:402:ineval'
from /home/Documents/maglev/HPI-GSS-BuildEnv/git/lib/ruby/1.8/irb.rb:159:in `eval_input'
from /home/.rbenv/versions/maglev/bin/maglev-irb:30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment