summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-12 07:41:35 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-12 07:41:35 +0000
commit14a730e91ee6176cc60ba3fc1cd368e47bd2f7b0 (patch)
tree4d355f722daedd8acdb45a77c0dbaf239f2713b3
parent257fd90166f62943ff767e5cd7b0624c12074a8b (diff)
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
-rw-r--r--compile.c5
-rw-r--r--eval_error.c2
-rw-r--r--iseq.c7
-rw-r--r--test/ruby/test_syntax.rb4
4 files changed, 15 insertions, 3 deletions
diff --git a/compile.c b/compile.c
index 9b0fbfa986..e521a27e6c 100644
--- a/compile.c
+++ b/compile.c
@@ -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 file = iseq->body->location.path;
- VALUE err = err_info;
+ VALUE err = err_info == Qtrue ? Qfalse : err_info;
va_list args;
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_set_errinfo(err);
}
+ else if (!err_info) {
+ RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->err_info, Qtrue);
+ }
}
static void
diff --git a/eval_error.c b/eval_error.c
index ff3db23a6b..b6f680748c 100644
--- a/eval_error.c
+++ b/eval_error.c
@@ -294,7 +294,7 @@ error_handle(int ex)
/* no message when exiting by signal */
}
else {
- error_print(th);
+ rb_threadptr_error_print(th, errinfo);
}
break;
}
diff --git a/iseq.c b/iseq.c
index 07d8828e9b..81edd37c47 100644
--- a/iseq.c
+++ b/iseq.c
@@ -272,6 +272,10 @@ prepare_iseq_build(rb_iseq_t *iseq,
const rb_compile_option_t *option)
{
VALUE coverage = Qfalse;
+ VALUE err_info = Qnil;
+
+ if (parent && (type == ISEQ_TYPE_MAIN || type == ISEQ_TYPE_TOP))
+ err_info = Qfalse;
iseq->body->type = type;
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));
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));
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);
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_exc_raise(err);
}
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 61aab4bee5..0f927a328e 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -975,6 +975,10 @@ eom
end;
end
+ def test_invalid_jump
+ assert_in_out_err(%w[-e redo], "", [], /^-e:1: /)
+ end
+
private
def not_label(x) @result = x; @not_label ||= nil end