aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-20 06:52:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-20 06:52:30 +0000
commit86b1179a03791002b6428f5b49754d7411933e9e (patch)
treedd7669603e35f7e216ebd92fe163828456dd2ae1
parente06aaf699d03daa4020d55c34876e5ec12f0e91d (diff)
downloadruby-86b1179a03791002b6428f5b49754d7411933e9e.tar.gz
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
-rw-r--r--ChangeLog8
-rw-r--r--error.c20
-rw-r--r--parse.y3
3 files changed, 29 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 3155dfe855..4dd2294c08 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/error.c b/error.c
index 89858719c1..214d12df5d 100644
--- a/error.c
+++ b/error.c
@@ -1362,6 +1362,25 @@ rb_invalid_str(const char *str, const char *type)
}
/*
+ * 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
*
* Ruby exception objects are subclasses of <code>Exception</code>.
@@ -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 */
diff --git a/parse.y b/parse.y
index 56f4d837c5..e3facb73c8 100644
--- a/parse.y
+++ b/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;