diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-11 06:39:08 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-11 06:39:08 +0000 |
commit | 5051186a0b1ca74a3fbd82714f93333995ea471e (patch) | |
tree | 35aa5bce370a8a68b483c6175d26abe5bc5c21be | |
parent | 5a5a86cc527946fb40f241377179b0723f2348db (diff) | |
download | ruby-5051186a0b1ca74a3fbd82714f93333995ea471e.tar.gz |
hash.c: warn for wrong elements
* hash.c (rb_hash_s_create): just warn for wrong elements now.
[ruby-dev:46440] [Bug #7300]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | hash.c | 8 | ||||
-rw-r--r-- | test/ruby/test_hash.rb | 4 |
3 files changed, 16 insertions, 3 deletions
@@ -1,4 +1,7 @@ -Sun Nov 11 15:38:14 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> +Sun Nov 11 15:39:04 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * hash.c (rb_hash_s_create): just warn for wrong elements now. + [ruby-dev:46440] [Bug #7300] * hash.c (rb_hash_s_create): refine error messages. @@ -28,7 +31,7 @@ Sun Nov 11 11:36:19 2012 Shugo Maeda <shugo@ruby-lang.org> * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo): add a new field for inline method cache. - * vm_insnhelper.c (vm_search_method): check rb_call_info_t::refinements + * vm_insnhelper.c (vm_search_method): check rb_call_info_t::refinements not to confuse inline method cache when module_eval is used with refinements. @@ -398,9 +398,17 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass) VALUE key, val = Qnil; if (NIL_P(v)) { +#if 0 /* refix in the next release */ rb_raise(rb_eArgError, "wrong element type %s at %ld (expected array)", rb_builtin_class_name(e), i); +#else + rb_warn("wrong element type %s at %ld (expected array)", + rb_builtin_class_name(e), i); + rb_warn("ignoring wrong elements is deprecated, remove them explicitly"); + rb_warn("this causes ArgumentError in the next release"); + continue; +#endif } switch (RARRAY_LEN(v)) { default: diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 076146f5a4..01a0706c3e 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1,5 +1,7 @@ +# -*- coding: us-ascii -*- require 'test/unit' require 'continuation' +require_relative 'envutil' class TestHash < Test::Unit::TestCase @@ -739,8 +741,8 @@ class TestHash < Test::Unit::TestCase def test_create assert_equal({1=>2, 3=>4}, Hash[[[1,2],[3,4]]]) assert_raise(ArgumentError) { Hash[0, 1, 2] } + assert_warning(/wrong element type Fixnum at 1 /) {Hash[[[1, 2], 3]]} bug5406 = '[ruby-core:39945]' - assert_raise(ArgumentError, bug5406) { Hash[[[1, 2], 3]] } assert_raise(ArgumentError, bug5406) { Hash[[[1, 2], [3, 4, 5]]] } assert_equal({1=>2, 3=>4}, Hash[1,2,3,4]) o = Object.new |