diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-11-11 17:51:31 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-11-22 00:33:19 +0900 |
commit | b7a0ce32da751b437b976b032e73281b9a56b509 (patch) | |
tree | 79f37befe380369ea3e0d0129feb0d390c14c22a /ruby.c | |
parent | 5b959e238e5b7c18d6a1a5f5d9b4b2063de628fe (diff) | |
download | ruby-b7a0ce32da751b437b976b032e73281b9a56b509.tar.gz |
[Bug #19016] `SyntaxError` with parser error messages
Raise a `SyntaxError` with the parser error message, in the case
reading from a file instead of the `-e` option or standard input. So
syntax_suggest can get the message from the caught error.
Diffstat (limited to 'ruby.c')
-rw-r--r-- | ruby.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -2085,11 +2085,11 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) ruby_set_argv(argc, argv); process_sflag(&opt->sflag); - rb_parser_set_context(parser, 0, TRUE); - if (opt->e_script) { VALUE progname = rb_progname; rb_encoding *eenc; + rb_parser_set_context(parser, 0, TRUE); + if (opt->src.enc.index >= 0) { eenc = rb_enc_from_index(opt->src.enc.index); } @@ -2114,6 +2114,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) else { VALUE f; f = open_load_file(script_name, &opt->xflag); + rb_parser_set_context(parser, 0, f == rb_stdin); ast = load_file(parser, opt->script_name, f, 1, opt); } ruby_set_script_name(opt->script_name); |