-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array include? rejects nil arguments #1482
Comments
It seems the argument of I can understand the definition because passing a non-string value is meaningless. Therefore I'm okay to detect errors if other types are passed (except nil). I agree that it's too strict to raise an error for a nil value. It's better to loosen the type of argument to BTW, your example let us know another problem between Integer and Float. In the case of numbers, it takes other number types as valid. From this perspective, other types should be accepted. |
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: soutaro/steep#1482
Yeah, this is incompatible with Ruby, intentionally. I think this is actually useful to detect a type error on a method call passing an unexpected object.
Your Passing some default value looks like another reasonable code to me. %w,true,.include?(ENV['foo'] || false) |
The following is valid and sensible Ruby code:
Here, we check if the environment variable is set to a particular value.
Steep rejects this with the following error:
Checking some other cases, steep seems to have its own idea of what can and cannot be in an array that does not match the functionality of Ruby. All of the following uses are rejected by steep:
The text was updated successfully, but these errors were encountered: