diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-10-20 14:07:35 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-10-20 15:35:31 +0900 |
commit | 7563604fb868d87057733f52d780d841fc1ab6bb (patch) | |
tree | 886c3624e49a970cd9469cf3e2a717c1e6735654 /object.c | |
parent | 4f1e0bfacd93c28bff549e2f3603c3b4942429a3 (diff) |
[Bug #18998] Honor `#to_str` next to `#to_int` in `Kernel#Integer`
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6598
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -3138,6 +3138,9 @@ rb_convert_to_integer(VALUE val, int base, int raise_exception) tmp = rb_protect(rb_check_to_int, val, NULL); if (RB_INTEGER_TYPE_P(tmp)) return tmp; rb_set_errinfo(Qnil); + if (!NIL_P(tmp = rb_check_string_type(val))) { + return rb_str_convert_to_inum(tmp, base, TRUE, raise_exception); + } if (!raise_exception) { VALUE result = rb_protect(rb_check_to_i, val, NULL); |