diff --git a/vm_eval.c b/vm_eval.c index 0dcbafa..85d6e28 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -960,10 +960,13 @@ 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 is_user_file = FALSE; if (file == 0) { file = rb_sourcefile(); line = rb_sourceline(); + } else { + is_user_file = TRUE; } parse_in_eval = th->parse_in_eval; @@ -977,7 +980,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 (!is_user_file && strcmp(file, "(eval)") == 0 && bind->filename != Qnil) { file = RSTRING_PTR(bind->filename); line = bind->line_no; } @@ -1035,7 +1038,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 (!is_user_file && strcmp(file, "(eval)") == 0) { VALUE mesg, errat, bt2; extern VALUE rb_get_backtrace(VALUE info); ID id_mesg;