From 527fa610870bd7823560ba7fda8e72e21fc42d7e Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 16 Feb 2016 09:25:08 +0000 Subject: [PATCH] numeric.c: fix segfault * numeric.c (compare_with_zero): fix variable name, rb_cmperr requires VALUEs but not an ID. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ numeric.c | 2 +- test/ruby/test_numeric.rb | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 12a8145f14..813d90f4ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Feb 16 18:24:38 2016 Nobuyoshi Nakada + + * numeric.c (compare_with_zero): fix variable name, rb_cmperr + requires VALUEs but not an ID. + Tue Feb 16 17:34:18 2016 Nobuyoshi Nakada * dir.c (rb_dir_s_empty_p): add Dir.empty? method, which tells the diff --git a/numeric.c b/numeric.c index 5e70cafdc9..6f094c1cde 100644 --- a/numeric.c +++ b/numeric.c @@ -168,7 +168,7 @@ compare_with_zero(VALUE num, ID mid) VALUE zero = INT2FIX(0); VALUE r = rb_check_funcall(num, mid, 1, &zero); if (r == Qundef) { - rb_cmperr(mid, zero); + rb_cmperr(num, zero); } return r; } diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb index 89e11d0ff8..5c55539d91 100644 --- a/test/ruby/test_numeric.rb +++ b/test/ruby/test_numeric.rb @@ -348,4 +348,14 @@ class TestNumeric < Test::Unit::TestCase assert_not_operator(1, :eql?, 1.0) assert_not_operator(1, :eql?, 2) end + + def test_coerced_remainder + assert_separately([], <<-'end;') + x = Class.new do + def coerce(a) [self, a]; end + def %(a) self; end + end.new + assert_raise(ArgumentError) {1.remainder(x)} + end; + end end