summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--NEWS4
-rw-r--r--class.c3
-rw-r--r--test/ruby/test_require.rb2
4 files changed, 12 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index aff8606662..a28e7f1340 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Jun 28 12:07:35 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * class.c (rb_define_class_id_under): raise TypeError exception
+ same as ruby level class definition when superclass mismatch.
+
Sun Jun 14 19:02:03 2015 Benoit Daloze <eregontp@gmail.com>
* lib/net/ftp.rb (makeport): close the TCPServer
diff --git a/NEWS b/NEWS
index b516ee88f4..b1e80ec764 100644
--- a/NEWS
+++ b/NEWS
@@ -143,6 +143,10 @@ with all sufficient information, see the ChangeLog file.
=== C API updates
+* rb_define_class_id_under() now raises a TypeError exception when the
+ class is already defined but its superclass does not match the given
+ superclass, as well as definitions in ruby level.
+
=== Build system updates
=== Implementation changes
diff --git a/class.c b/class.c
index f963f0c22a..991172acbb 100644
--- a/class.c
+++ b/class.c
@@ -703,7 +703,8 @@ rb_define_class_id_under(VALUE outer, ID id, VALUE super)
rb_raise(rb_eTypeError, "%"PRIsVALUE" is not a class", rb_id2str(id));
}
if (rb_class_real(RCLASS_SUPER(klass)) != super) {
- rb_name_error(id, "%"PRIsVALUE" is already defined", rb_id2str(id));
+ rb_raise(rb_eTypeError, "superclass mismatch for class %"PRIsVALUE"",
+ rb_id2str(id));
}
return klass;
}
diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb
index e7a903d658..7c2a5d3aa8 100644
--- a/test/ruby/test_require.rb
+++ b/test/ruby/test_require.rb
@@ -228,7 +228,7 @@ class TestRequire < Test::Unit::TestCase
assert_separately([], <<-INPUT)
module Zlib; end
class Zlib::Error; end
- assert_raise(NameError) do
+ assert_raise(TypeError) do
require 'zlib'
end
INPUT