ruby-changes:37232
From: naruse <ko1@a...>
Date: Sun, 18 Jan 2015 01:00:20 +0900 (JST)
Subject: [ruby-changes:37232] naruse:r49313 (ruby_2_2): merge revision(s) 49224, 49234, 49235: [Backport #10711]
naruse 2015-01-18 01:00:11 +0900 (Sun, 18 Jan 2015) New Revision: 49313 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49313 Log: merge revision(s) 49224,49234,49235: [Backport #10711] * numeric.c (bit_coerce): use original value for error message [ruby-core:67405] [Bug #10711] * test/ruby/test_numeric.rb (test_coerce): check error message Modified directories: branches/ruby_2_2/ Modified files: branches/ruby_2_2/ChangeLog branches/ruby_2_2/compar.c branches/ruby_2_2/numeric.c branches/ruby_2_2/test/ruby/test_numeric.rb branches/ruby_2_2/version.h Index: ruby_2_2/ChangeLog =================================================================== --- ruby_2_2/ChangeLog (revision 49312) +++ ruby_2_2/ChangeLog (revision 49313) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1 +Sun Jan 18 00:59:41 2015 Eric Wong <e@8...> + + * numeric.c (bit_coerce): use original value for error message + [ruby-core:67405] [Bug #10711] + * test/ruby/test_numeric.rb (test_coerce): check error message + Sun Jan 18 00:53:38 2015 Seiei Higa <hanachin@g...> * vm_method.c (rb_alias): raise a NameError when creating alias to Index: ruby_2_2/numeric.c =================================================================== --- ruby_2_2/numeric.c (revision 49312) +++ ruby_2_2/numeric.c (revision 49313) @@ -237,9 +237,14 @@ NORETURN(static void coerce_failed(VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_2/numeric.c#L237 static void coerce_failed(VALUE x, VALUE y) { + if (SPECIAL_CONST_P(y) || BUILTIN_TYPE(y) == T_FLOAT) { + y = rb_inspect(y); + } + else { + y = rb_obj_class(y); + } rb_raise(rb_eTypeError, "%"PRIsVALUE" can't be coerced into %"PRIsVALUE, - (rb_special_const_p(y)? rb_inspect(y) : rb_obj_class(y)), - rb_obj_class(x)); + y, rb_obj_class(x)); } static VALUE @@ -3426,10 +3431,11 @@ static int https://github.com/ruby/ruby/blob/trunk/ruby_2_2/numeric.c#L3431 bit_coerce(VALUE *x, VALUE *y) { if (!FIXNUM_P(*y) && !RB_TYPE_P(*y, T_BIGNUM)) { + VALUE orig = *x; do_coerce(x, y, TRUE); if (!FIXNUM_P(*x) && !RB_TYPE_P(*x, T_BIGNUM) && !FIXNUM_P(*y) && !RB_TYPE_P(*y, T_BIGNUM)) { - coerce_failed(*x, *y); + coerce_failed(orig, *y); } } return TRUE; Index: ruby_2_2/compar.c =================================================================== --- ruby_2_2/compar.c (revision 49312) +++ ruby_2_2/compar.c (revision 49313) @@ -20,7 +20,7 @@ rb_cmperr(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/compar.c#L20 { VALUE classname; - if (SPECIAL_CONST_P(y)) { + if (SPECIAL_CONST_P(y) || BUILTIN_TYPE(y) == T_FLOAT) { classname = rb_inspect(y); } else { Index: ruby_2_2/version.h =================================================================== --- ruby_2_2/version.h (revision 49312) +++ ruby_2_2/version.h (revision 49313) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #define RUBY_VERSION "2.2.0" #define RUBY_RELEASE_DATE "2015-01-18" -#define RUBY_PATCHLEVEL 25 +#define RUBY_PATCHLEVEL 26 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 Index: ruby_2_2/test/ruby/test_numeric.rb =================================================================== --- ruby_2_2/test/ruby/test_numeric.rb (revision 49312) +++ ruby_2_2/test/ruby/test_numeric.rb (revision 49313) @@ -32,6 +32,10 @@ class TestNumeric < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_numeric.rb#L32 assert_raise_with_message(TypeError, /:"\\u3042"/) {1|:"\u{3042}"} assert_raise_with_message(TypeError, /:"\\u3042"/) {1^:"\u{3042}"} end + + bug10711 = '[ruby-core:67405] [Bug #10711]' + exp = "Float can't be coerced into Fixnum" + assert_raise_with_message(TypeError, exp, bug10711) { 1 & 1.2 } end def test_dummynumeric Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r49224,49234-49235 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/