From 9e8dfaa8b09b285a1260a6b97ecfac663fb79107 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 20 Apr 2016 02:52:07 +0000 Subject: 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 --- compile.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'compile.c') diff --git a/compile.c b/compile.c index 63be63c13d..902496e098 100644 --- a/compile.c +++ b/compile.c @@ -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 file = iseq->body->location.path; + VALUE err = err_info; va_list args; 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); + if (NIL_P(err_info)) { + RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->err_info, err); + rb_set_errinfo(err); + } } static void @@ -341,13 +346,7 @@ NOINLINE(static compile_error_func prepare_compile_error(rb_iseq_t *iseq)); static compile_error_func prepare_compile_error(rb_iseq_t *iseq) { - VALUE err_info = ISEQ_COMPILE_DATA(iseq)->err_info; 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; } -- cgit v1.2.3