Exception message when requiring buggy code

e$B1sF#$G$9!#e(B

require e$B$,%Q!<%9;~$K<:GT$9$k$H0J2<$N$h$&$KDL>o$NNc30$K$J$j$^$9$,!"e(B

$ cat foo.rb
"foo

$ ./ruby -e ’
begin
require “foo.rb”
rescue SyntaxError
p $!
end

#<SyntaxError: /home/mame/work/ruby19/ruby/foo.rb:1: unterminated
string meets end of file>

e$B%3%s%Q%$%k;~$K<:GT$9$k$HI8=`%(%i!<=PNO$K$J$s$+=P$F$-$^$9!#e(B

$ cat bar.rb
break

$ ./ruby -e ’
begin
require “bar.rb”
rescue SyntaxError
p $!
end

/home/mame/work/ruby19/ruby/bar.rb:1: Invalid break
#<SyntaxError: compile error>

eval e$B$G$O%Q!<%9;~$G$b%3%s%Q%$%k;~$G$bDL>o$NNc30$K$J$j$^$9!#e(B

$ ./ruby -e ’
begin
eval "“foo”
rescue SyntaxError
p $!
end

#<SyntaxError: (eval):1: unterminated string meets end of file>

$ ./ruby -e ’
begin
eval “break”
rescue SyntaxError
p $!
end

#<SyntaxError: (eval):1: Can’t escape from eval with break>

e$B0J>e$N5sF0$O0U?^E*$G$7$g$&$+!#e(B

e$B;d$N46@-$G$O!"e(Brequire
e$B$N%3%s%Q%$%k;~$N<:GT$G$bDL>o$NNc30$K$9$k$N$,e(B
e$B$$$$$H;W$$$^$7$?!#0J2<$O$=$&$9$k%Q%C%A$G$9!#e(B

e$B$3$N46@-$,@5$7$1$l$P!"e(Bparse_in_eval e$B$H$$$&%U%i%0$NL>A0$Oe(B

parse_and_compile_in_eval

e$B$H$+$$$&J}$,<BBN$K$"$C$F$$$k5$$,$7$^$9!#e(B

e$B%j%U%!%/%?%j%s%0$9$Y$-!)e(B

Index: load.c

— load.c (revision 17562)
+++ load.c (working copy)
@@ -276,10 +276,10 @@

th->parse_in_eval++;
node = (NODE *)rb_load_file(RSTRING_PTR(fname));

  • th->parse_in_eval–;
    loaded = Qtrue;
    iseq = rb_iseq_new(node, rb_str_new2("<top (required)>"),
    fname, Qfalse, ISEQ_TYPE_TOP);
  • th->parse_in_eval–;
    rb_iseq_eval(iseq);
    }
    POP_TAG();