1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

compile.c: make SyntaxError after formatting

* compile.c (append_compile_error): make SyntaxError instance by
  rb_syntax_error_append on demand after formatting the message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-04-20 02:52:07 +00:00
parent 7f5f5e80d5
commit 9e8dfaa8b0

View file

@ -319,11 +319,16 @@ 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;
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
rb_syntax_error_append(err_info, file, line, -1, NULL, fmt, args); err = rb_syntax_error_append(err, file, line, -1, NULL, fmt, args);
va_end(args); va_end(args);
if (NIL_P(err_info)) {
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->err_info, err);
rb_set_errinfo(err);
}
} }
static void static void
@ -341,13 +346,7 @@ NOINLINE(static compile_error_func prepare_compile_error(rb_iseq_t *iseq));
static compile_error_func static compile_error_func
prepare_compile_error(rb_iseq_t *iseq) prepare_compile_error(rb_iseq_t *iseq)
{ {
VALUE err_info = ISEQ_COMPILE_DATA(iseq)->err_info;
if (compile_debug) return &compile_bug; if (compile_debug) return &compile_bug;
if (NIL_P(err_info)) {
err_info = rb_exc_new_cstr(rb_eSyntaxError, "");
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->err_info, err_info);
}
rb_set_errinfo(err_info);
return &append_compile_error; return &append_compile_error;
} }