e$B%A%1%C%He(B #1769 e$B$,99?7$5$l$^$7$?!#e(B (by Yusuke E.)
e$BC4Ev<Te(B Koichi Sasadae$B$+$ie(BYusuke E.e$B$KJQ99e(B
e$B1sF#$G$9!#e(B
evale$B$NBhe(B3, 4e$B0z?t$r>JN,$7$?:]$Ke(Bbindinge$B$,;}$C$F$$$ke(Bfile, linee$B$,EAGE$7$J$/e(B
e$B$J$C$F$$$^$9!#$3$l$O0U?^$7$?$3$H$G$7$g$&$+!#e(B
rb_binding_t e$B$K%U%!%$%kL>$H9THV9f$r;}$?$;$F$_$^$7$?!#e(B
bootstraptest/test_eval.rb e$B$Ke(B 1 e$B$+=j!"e(Brubyspec e$B$Ke(B 4
e$B2U=j=$@5$re(B
e$B2C$($?>e$G!"e(Bmake check e$B$He(B make test-rubyspec
e$B$rDL2a$7$^$7$?!#e(B
e$BH?BP$,$J$1$l$P%3%_%C%H$7$^$9!#e(B
diff --git a/bootstraptest/test_eval.rb b/bootstraptest/test_eval.rb
index c5ab953…9ae50a6 100644
— a/bootstraptest/test_eval.rb
+++ b/bootstraptest/test_eval.rb
@@ -287,7 +287,7 @@ assert_normal_exit %q{
eval(“”, method(:proc).call {}.binding)
}
-assert_equal "(eval):1:in `block in ‘: ", %q{
+assert_equal “”, %q{
b = binding
10.times{
eval(’', b)
diff --git a/proc.c b/proc.c
index 7e8e0e1…035897c 100644
— a/proc.c
+++ b/proc.c
@@ -254,6 +254,7 @@ binding_mark(void *ptr)
if (ptr) {
bind = ptr;
RUBY_MARK_UNLESS_NULL(bind->env);
- RUBY_MARK_UNLESS_NULL(bind->filename);
}
RUBY_MARK_LEAVE(“binding”);
}
@@ -289,6 +290,8 @@ binding_dup(VALUE self)
GetBindingPtr(self, src);
GetBindingPtr(bindval, dst);
dst->env = src->env;
- dst->filename = src->filename;
- dst->line_no = src->line_no;
return bindval;
}
@@ -315,6 +318,8 @@ rb_binding_new(void)
GetBindingPtr(bindval, bind);
bind->env = rb_vm_make_env_object(th, cfp);
- bind->filename = cfp->iseq->filename;
- bind->line_no = rb_vm_get_sourceline(cfp);
return bindval;
}
@@ -1893,6 +1898,8 @@ proc_binding(VALUE self)
bindval = binding_alloc(rb_cBinding);
GetBindingPtr(bindval, bind);
bind->env = proc->envval;
- bind->filename = proc->block.iseq->filename;
- bind->line_no = rb_iseq_first_lineno(proc->block.iseq);
return bindval;
}
diff --git a/vm_core.h b/vm_core.h
index b5c1bf0…15f7c59 100644
— a/vm_core.h
+++ b/vm_core.h
@@ -519,6 +519,8 @@ typedef struct {
typedef struct {
VALUE env;
- VALUE filename;
- unsigned short line_no;
} rb_binding_t;
/* used by compile time and send insn */
diff --git a/vm_eval.c b/vm_eval.c
index fefe6d6…9806762 100644
— a/vm_eval.c
+++ b/vm_eval.c
@@ -963,6 +963,10 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE
scope, NODE *cref, const char
if (rb_obj_is_kind_of(scope, rb_cBinding)) {
GetBindingPtr(scope, bind);
envval = bind->env;
rubyspec e$BB&$N%Q%C%Ae(B:
diff --git a/core/kernel/caller_spec.rb b/core/kernel/caller_spec.rb
index 3ecde8a…923a1ec 100644
— a/core/kernel/caller_spec.rb
+++ b/core/kernel/caller_spec.rb
@@ -93,7 +93,7 @@ describe “Kernel#caller in a Proc or eval” do
ruby_version_is “1.9” do
it “returns the definition trace of a block when evaluated in a
Proc binding” do
stack = CallerFixture.caller_of(CallerFixture.block)
(required)>‘/
stack[1].should =~ /caller_fixture2.rb:18:in eval'/ stack[2].should =~ /caller_fixture2\.rb:18:in
caller_of’/
stack[3].should =~ /caller_spec.rb:95:in `block (3 levels) in
<top (required)>'/
@@ -101,7 +101,7 @@ describe “Kernel#caller in a Proc or eval” do
it "returns the definition trace of a Proc" do
stack = CallerFixture.caller_of(CallerFixture.example_proc)
<top (required)>'/
@@ -119,7 +119,7 @@ describe “Kernel#caller in a Proc or eval” do
# the correct behaviour
it “returns the correct definition line for a complex Proc trace”
do
stack = CallerFixture.caller_of(CallerFixture.entry_point)
<top (required)>'/
diff --git a/core/kernel/eval_spec.rb b/core/kernel/eval_spec.rb
index 187c8f3…4bc731b 100644
— a/core/kernel/eval_spec.rb
+++ b/core/kernel/eval_spec.rb
@@ -252,26 +252,13 @@ describe “Kernel#eval” do
end
end
- ruby_version_is “”…“1.9” do
- it “uses the filename of the binding if none is provided” do
-
eval("__FILE__").should == "(eval)"
-
eval("__FILE__", binding).should == __FILE__
-
eval("__FILE__", binding, "success").should == "success"
-
eval("eval '__FILE__', binding").should == "(eval)"
-
eval("eval '__FILE__', binding", binding).should == __FILE__
-
eval("eval '__FILE__', binding", binding, 'success').should ==
‘success’
- end
- end
-
- ruby_version_is “1.9” do
- it “uses a filename of (eval) if none is provided” do
-
eval("__FILE__").should == "(eval)"
-
eval("__FILE__", binding).should == "(eval)"
-
eval("__FILE__", binding, "success").should == "success"
-
eval("eval '__FILE__', binding").should == "(eval)"
-
eval("eval '__FILE__', binding", binding).should == "(eval)"
-
eval("eval '__FILE__', binding", binding, 'success').should ==
‘(eval)’
- it “uses the filename of the binding if none is provided” do
- eval(“FILE”).should == “(eval)”
- eval(“FILE”, binding).should == FILE
- eval(“FILE”, binding, “success”).should == “success”
- eval(“eval ‘FILE’, binding”).should == “(eval)”
- eval(“eval ‘FILE’, binding”, binding).should == FILE
- eval(“eval ‘FILE’, binding”, binding, ‘success’).should ==
‘success’
end
Found via Rubinius bug github:#149
http://redmine.ruby-lang.org/issues/show/1769