immediate message mode of compile error
* compile.c (append_compile_error): set Qtrue for erred state with showing the message immediately. * iseq.c (prepare_iseq_build): make immediate message mode if main or top level context, not to show the failed path twice in the first line. * iseq.c (cleanup_iseq_build): raise default message exception if immediate message mode. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
257fd90166
commit
14a730e91e
@ -337,7 +337,7 @@ append_compile_error(rb_iseq_t *iseq, int line, const char *fmt, ...)
|
|||||||
{
|
{
|
||||||
VALUE err_info = ISEQ_COMPILE_DATA(iseq)->err_info;
|
VALUE err_info = ISEQ_COMPILE_DATA(iseq)->err_info;
|
||||||
VALUE file = iseq->body->location.path;
|
VALUE file = iseq->body->location.path;
|
||||||
VALUE err = err_info;
|
VALUE err = err_info == Qtrue ? Qfalse : err_info;
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
@ -347,6 +347,9 @@ append_compile_error(rb_iseq_t *iseq, int line, const char *fmt, ...)
|
|||||||
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->err_info, err);
|
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->err_info, err);
|
||||||
rb_set_errinfo(err);
|
rb_set_errinfo(err);
|
||||||
}
|
}
|
||||||
|
else if (!err_info) {
|
||||||
|
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->err_info, Qtrue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -294,7 +294,7 @@ error_handle(int ex)
|
|||||||
/* no message when exiting by signal */
|
/* no message when exiting by signal */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
error_print(th);
|
rb_threadptr_error_print(th, errinfo);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
7
iseq.c
7
iseq.c
@ -272,6 +272,10 @@ prepare_iseq_build(rb_iseq_t *iseq,
|
|||||||
const rb_compile_option_t *option)
|
const rb_compile_option_t *option)
|
||||||
{
|
{
|
||||||
VALUE coverage = Qfalse;
|
VALUE coverage = Qfalse;
|
||||||
|
VALUE err_info = Qnil;
|
||||||
|
|
||||||
|
if (parent && (type == ISEQ_TYPE_MAIN || type == ISEQ_TYPE_TOP))
|
||||||
|
err_info = Qfalse;
|
||||||
|
|
||||||
iseq->body->type = type;
|
iseq->body->type = type;
|
||||||
set_relation(iseq, parent);
|
set_relation(iseq, parent);
|
||||||
@ -286,7 +290,7 @@ prepare_iseq_build(rb_iseq_t *iseq,
|
|||||||
RB_OBJ_WRITE(iseq, &iseq->body->mark_ary, iseq_mark_ary_create(0));
|
RB_OBJ_WRITE(iseq, &iseq->body->mark_ary, iseq_mark_ary_create(0));
|
||||||
|
|
||||||
ISEQ_COMPILE_DATA(iseq) = ZALLOC(struct iseq_compile_data);
|
ISEQ_COMPILE_DATA(iseq) = ZALLOC(struct iseq_compile_data);
|
||||||
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->err_info, Qnil);
|
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->err_info, err_info);
|
||||||
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->mark_ary, rb_ary_tmp_new(3));
|
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->mark_ary, rb_ary_tmp_new(3));
|
||||||
|
|
||||||
ISEQ_COMPILE_DATA(iseq)->storage_head = ISEQ_COMPILE_DATA(iseq)->storage_current =
|
ISEQ_COMPILE_DATA(iseq)->storage_head = ISEQ_COMPILE_DATA(iseq)->storage_current =
|
||||||
@ -325,6 +329,7 @@ cleanup_iseq_build(rb_iseq_t *iseq)
|
|||||||
compile_data_free(data);
|
compile_data_free(data);
|
||||||
|
|
||||||
if (RTEST(err)) {
|
if (RTEST(err)) {
|
||||||
|
if (err == Qtrue) err = rb_exc_new_cstr(rb_eSyntaxError, "compile error");
|
||||||
rb_funcallv(err, rb_intern("set_backtrace"), 1, &iseq->body->location.path);
|
rb_funcallv(err, rb_intern("set_backtrace"), 1, &iseq->body->location.path);
|
||||||
rb_exc_raise(err);
|
rb_exc_raise(err);
|
||||||
}
|
}
|
||||||
|
@ -975,6 +975,10 @@ eom
|
|||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_invalid_jump
|
||||||
|
assert_in_out_err(%w[-e redo], "", [], /^-e:1: /)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def not_label(x) @result = x; @not_label ||= nil end
|
def not_label(x) @result = x; @not_label ||= nil end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user