mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
rational.c: ensure to be Rational
* rational.c (f_round_common): Rational is expected to be returned by Rational#*, but mathn.rb breaks that assumption. [ruby-core:56177] [Bug #8687] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0f12658995
commit
8974d5aaa7
3 changed files with 111 additions and 1 deletions
|
@ -1285,6 +1285,10 @@ f_round_common(int argc, VALUE *argv, VALUE self, VALUE (*func)(VALUE))
|
|||
return self;
|
||||
}
|
||||
|
||||
if (!k_rational_p(s)) {
|
||||
s = f_rational_new_bang1(CLASS_OF(self), s);
|
||||
}
|
||||
|
||||
s = (*func)(s);
|
||||
|
||||
s = f_div(f_rational_new_bang1(CLASS_OF(self), s), b);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue