mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
error.c: SyntaxError#initialize
* error.c (syntax_error_initialize): move the default message, "compile error", from parse.y. the default parameter should belong to the class definition. * parse.y (yycompile0): use the default parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e06aaf699d
commit
86b1179a03
3 changed files with 29 additions and 2 deletions
|
@ -1,3 +1,11 @@
|
|||
Wed Apr 20 15:52:28 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* error.c (syntax_error_initialize): move the default message,
|
||||
"compile error", from parse.y. the default parameter should
|
||||
belong to the class definition.
|
||||
|
||||
* parse.y (yycompile0): use the default parameter.
|
||||
|
||||
Wed Apr 20 10:25:53 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* compile.c (append_compile_error): use rb_syntax_error_append.
|
||||
|
|
20
error.c
20
error.c
|
@ -1361,6 +1361,25 @@ rb_invalid_str(const char *str, const char *type)
|
|||
rb_raise(rb_eArgError, "invalid value for %s: %+"PRIsVALUE, type, s);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* SyntaxError.new([msg]) -> syntax_error
|
||||
*
|
||||
* Construct a SyntaxError exception.
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
syntax_error_initialize(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE mesg;
|
||||
if (argc == 0) {
|
||||
mesg = rb_fstring_cstr("compile error");
|
||||
argc = 1;
|
||||
argv = &mesg;
|
||||
}
|
||||
return rb_call_super(argc, argv);
|
||||
}
|
||||
|
||||
/*
|
||||
* Document-module: Errno
|
||||
*
|
||||
|
@ -1960,6 +1979,7 @@ Init_Exception(void)
|
|||
|
||||
rb_eScriptError = rb_define_class("ScriptError", rb_eException);
|
||||
rb_eSyntaxError = rb_define_class("SyntaxError", rb_eScriptError);
|
||||
rb_define_method(rb_eSyntaxError, "initialize", syntax_error_initialize, -1);
|
||||
|
||||
rb_eLoadError = rb_define_class("LoadError", rb_eScriptError);
|
||||
/* the path failed to load */
|
||||
|
|
3
parse.y
3
parse.y
|
@ -5551,8 +5551,7 @@ yycompile0(VALUE arg)
|
|||
if (parser->error_p) {
|
||||
VALUE mesg = parser->error_buffer;
|
||||
if (!mesg) {
|
||||
mesg = rb_fstring_cstr("compile error");
|
||||
mesg = rb_exc_new_str(rb_eSyntaxError, mesg);
|
||||
mesg = rb_class_new_instance(0, 0, rb_eSyntaxError);
|
||||
}
|
||||
rb_set_errinfo(mesg);
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue