Project

General

Profile

Bug #14552

Kernel#Integer can return a non-Integer object.

Added by mrkn (Kenta Murata) over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 2.6.0dev (2018-02-25 trunk 62575) [x86_64-darwin16]
[ruby-core:85813]

Description

I found a bug that Kernel#Integer returns any non-nil object which is a result of to_int.

obj = Object.new
def obj.to_int
  "str"
end
Integer(obj) #=> "str"

Associated revisions

Revision cc4be225
Added by mrkn (Kenta Murata) over 1 year ago

Check the result of to_int in Kernel#Integer

[ruby-core:85813] [Bug #14552]

  • object.c (rb_convert_to_integer):
    Check the result of to_int in Kernel#Integer

  • test/ruby/test_integer.rb: add tests.

  • spec/ruby/core/kernel/Integer_spec.rb: fix examples.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 62581
Added by mrkn (Kenta Murata) over 1 year ago

Check the result of to_int in Kernel#Integer

[ruby-core:85813] [Bug #14552]

  • object.c (rb_convert_to_integer):
    Check the result of to_int in Kernel#Integer

  • test/ruby/test_integer.rb: add tests.

  • spec/ruby/core/kernel/Integer_spec.rb: fix examples.

Revision 62581
Added by mrkn (Kenta Murata) over 1 year ago

Check the result of to_int in Kernel#Integer

[ruby-core:85813] [Bug #14552]

  • object.c (rb_convert_to_integer):
    Check the result of to_int in Kernel#Integer

  • test/ruby/test_integer.rb: add tests.

  • spec/ruby/core/kernel/Integer_spec.rb: fix examples.

History

#1

Updated by mrkn (Kenta Murata) over 1 year ago

  • Status changed from Assigned to Closed

Applied in changeset trunk|r62581.


Check the result of to_int in Kernel#Integer

[ruby-core:85813] [Bug #14552]

  • object.c (rb_convert_to_integer):
    Check the result of to_int in Kernel#Integer

  • test/ruby/test_integer.rb: add tests.

  • spec/ruby/core/kernel/Integer_spec.rb: fix examples.

Also available in: Atom PDF