aboutsummaryrefslogtreecommitdiffstats
path: root/numeric.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2023-05-29 10:45:31 -0400
committerPeter Zhu <peter@peterzhu.ca>2023-05-29 11:55:39 -0400
commitb7a26dfa16228cdfeb7e635df1e4f711908c667c (patch)
tree4990a51068ceda8097098d1755598f6de518d53e /numeric.c
parentc48d496e8cfdf8243d2beb28623954003adaf7fc (diff)
downloadruby-b7a26dfa16228cdfeb7e635df1e4f711908c667c.tar.gz
Unify error messages of rb_num2ulong and rb_num2ull
The error messages were slightly different due, which causes different behaviour on 32-bit and 64-bit systems.
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/numeric.c b/numeric.c
index 224b5c7dc2..8cad7ff670 100644
--- a/numeric.c
+++ b/numeric.c
@@ -3165,7 +3165,7 @@ rb_num2ulong_internal(VALUE val, int *wrap_p)
{
again:
if (NIL_P(val)) {
- rb_raise(rb_eTypeError, "no implicit conversion from nil to integer");
+ rb_raise(rb_eTypeError, "no implicit conversion of nil into Integer");
}
if (FIXNUM_P(val)) {
@@ -3440,7 +3440,7 @@ unsigned LONG_LONG
rb_num2ull(VALUE val)
{
if (NIL_P(val)) {
- rb_raise(rb_eTypeError, "no implicit conversion from nil");
+ rb_raise(rb_eTypeError, "no implicit conversion of nil into Integer");
}
else if (FIXNUM_P(val)) {
return (LONG_LONG)FIX2LONG(val); /* this is FIX2LONG, intended */
@@ -3459,15 +3459,10 @@ rb_num2ull(VALUE val)
else if (RB_BIGNUM_TYPE_P(val)) {
return rb_big2ull(val);
}
- else if (RB_TYPE_P(val, T_STRING)) {
- rb_raise(rb_eTypeError, "no implicit conversion from string");
- }
- else if (RB_TYPE_P(val, T_TRUE) || RB_TYPE_P(val, T_FALSE)) {
- rb_raise(rb_eTypeError, "no implicit conversion from boolean");
+ else {
+ val = rb_to_int(val);
+ return NUM2ULL(val);
}
-
- val = rb_to_int(val);
- return NUM2ULL(val);
}
#endif /* HAVE_LONG_LONG */