diff --git a/vm_eval.c b/vm_eval.c index 0dcbafa..b2b9fea 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -960,10 +960,12 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, const char rb_block_t block; volatile int parse_in_eval; volatile int mild_compile_error; + volatile int has_empty_file_arg = FALSE; if (file == 0) { file = rb_sourcefile(); line = rb_sourceline(); + has_empty_file_arg = TRUE; } parse_in_eval = th->parse_in_eval; @@ -977,7 +979,7 @@ 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; - if (strcmp(file, "(eval)") == 0 && bind->filename != Qnil) { + if (has_empty_file_arg && strcmp(file, "(eval)") == 0 && bind->filename != Qnil) { file = RSTRING_PTR(bind->filename); line = bind->line_no; } @@ -1035,7 +1037,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, const char if (state) { if (state == TAG_RAISE) { VALUE errinfo = th->errinfo; - if (strcmp(file, "(eval)") == 0) { + if (has_empty_file_arg && strcmp(file, "(eval)") == 0) { VALUE mesg, errat, bt2; extern VALUE rb_get_backtrace(VALUE info); ID id_mesg;