aboutsummaryrefslogtreecommitdiffstats
path: root/compile.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-20 02:52:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-20 02:52:07 +0000
commit9e8dfaa8b09b285a1260a6b97ecfac663fb79107 (patch)
treeaeebf64704b5b31df8787a834a6fa4f5322fedef /compile.c
parent7f5f5e80d52e3b44645de2cac5aa8b7d3835f8df (diff)
downloadruby-9e8dfaa8b09b285a1260a6b97ecfac663fb79107.tar.gz
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
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c13
1 files changed, 6 insertions, 7 deletions
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;
}