diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-09-27 08:35:31 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-09-27 08:35:31 +0000 |
commit | a38b2f84f468638bb910455fe618cae4c431d893 (patch) | |
tree | adb6bcffc42f84464b87227b01889c104ce428ca /iseq.c | |
parent | 2ca58e42904db6de1d4b30ad5c618205bad8b313 (diff) |
iseq.c: syntax error in compile_file
* iseq.c (iseqw_s_compile_file): deal with syntax error as well as
compile, and should not abort when rescued.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r-- | iseq.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -823,8 +823,7 @@ static VALUE iseqw_s_compile_file(int argc, VALUE *argv, VALUE self) { VALUE file, line = INT2FIX(1), opt = Qnil; - VALUE parser; - VALUE f; + VALUE parser, f, exc = Qnil; NODE *node; rb_compile_option_t option; int i; @@ -841,9 +840,12 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self) f = rb_file_open_str(file, "r"); parser = rb_parser_new(); + rb_parser_set_context(parser, NULL, FALSE); node = rb_parser_compile_file_path(parser, file, f, NUM2INT(line)); + if (!node) exc = GET_THREAD()->errinfo; rb_io_close(f); + if (!node) rb_exc_raise(exc); make_compile_option(&option, opt); |