From 43b78d2e86dcbdf09fd1e418fefb8ad605c2975d Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 12 Feb 2025 03:51:04 +0900 Subject: [PATCH] core: Array#include? and Enumerable#include? should take non-Elem types For example, `Array[Integer]` can take other number types validly: ``` > [1, 2, 3].include? 2.0 => true > [1, 2, 3].include? Complex(2) => true > [1, 2, 3].include? Rational(2) => true ``` refs: https://github.com/soutaro/steep/issues/1482 --- core/array.rbs | 2 +- core/enumerable.rbs | 2 +- test/stdlib/Array_test.rb | 2 ++ test/stdlib/Enumerable_test.rb | 7 +++++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/core/array.rbs b/core/array.rbs index a368c1c23..e6f0f13dc 100644 --- a/core/array.rbs +++ b/core/array.rbs @@ -2182,7 +2182,7 @@ class Array[unchecked out Elem] < Object # # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying). # - def include?: (Elem object) -> bool + def include?: (untyped object) -> bool # # Returns the zero-based integer index of a specified element, or `nil`. diff --git a/core/enumerable.rbs b/core/enumerable.rbs index e0368f5c6..93694cc11 100644 --- a/core/enumerable.rbs +++ b/core/enumerable.rbs @@ -718,7 +718,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem] # {foo: 0, bar: 1, baz: 2}.include?('foo') # => false # {foo: 0, bar: 1, baz: 2}.include?(0) # => false # - def include?: (Elem arg0) -> bool + def include?: (untyped arg0) -> bool #