diff --git a/ChangeLog b/ChangeLog index 49b1a8976b..3a4145ff55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ -Sun Nov 11 15:38:14 2012 Nobuyoshi Nakada +Sun Nov 11 15:39:04 2012 Nobuyoshi Nakada + + * 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 * 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. diff --git a/hash.c b/hash.c index c3e5931be0..c6ce897e53 100644 --- a/hash.c +++ b/hash.c @@ -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