Merge pull request #3192 from ksss/instance_eval

instance_eval env should remake Fix #3191
This commit is contained in:
Yukihiro "Matz" Matsumoto
2016-08-31 23:15:42 +09:00
committed by GitHub
2 changed files with 3 additions and 0 deletions
+1
View File
@@ -247,6 +247,7 @@ f_instance_eval(mrb_state *mrb, mrb_value self)
cv = mrb_singleton_class(mrb, self);
c->ci->target_class = mrb_class_ptr(cv);
proc = create_proc_from_string(mrb, s, len, mrb_nil_value(), file, line);
mrb->c->ci->env = NULL;
return mrb_vm_run(mrb, proc, mrb->c->stack[0], 0);
}
else {
+2
View File
@@ -64,6 +64,8 @@ assert('String instance_eval') do
assert_equal(['test.rb', 10]) { obj.instance_eval('[__FILE__, __LINE__]', 'test.rb', 10)}
assert_equal('test') { obj.instance_eval('@test') }
assert_equal('test') { obj.instance_eval { @test } }
o = Object.new
assert_equal ['', o, o], o.instance_eval("[''].each { |s| break [s, o, self] }")
end
assert('Kernel.#eval(string) context') do