You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead, the __callee__ invocation has to be asserted as non-nil, by wrapping in T.must:
deffor(x,y=1)to_enum(T.must(__callee__),x,y)end
I believe that this formulation should be accepted by rubocop.
Actual behavior
The last example above triggers a rubocop violation:
foo.rb:10:3: W: Lint/ToEnumArguments: Ensure you correctly provided all the arguments.
to_enum(T.must(__callee__), x, y)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Steps to reproduce the problem
Invoke rubocop foo.rb --only Lint/ToEnumArguments, where foo.rb contains the following:
Fixesrubocop#11591.
THis PR fixes a false positive for `Lint/ToEnumArguments`
when enumerator is not created for `__callee__` and `__callee__` methods.
Expected behavior
The "good" example for
Lint/ToEnumArguments
looks like this:However, since
__callee__
and__method__
can returnnil
, these are not viable in a type-checked ruby context, Sorbet in particular:https://sorbet.run/#%23%20frozen_string_literal%3A%20true%0A%0Aextend%20T%3A%3ASig%0A%0Adef%20foo%28x%2C%20y%20%3D%201%29%0A%20%20to_enum%28__callee__%2C%20x%2C%20y%29%0Aend%0A%0Adef%20bar%28x%2C%20y%20%3D%201%29%0A%20%20to_enum%28T.must%28__callee__%29%2C%20x%2C%20y%29%0Aend
Instead, the
__callee__
invocation has to be asserted as non-nil
, by wrapping inT.must
:I believe that this formulation should be accepted by
rubocop
.Actual behavior
The last example above triggers a rubocop violation:
Steps to reproduce the problem
Invoke
rubocop foo.rb --only Lint/ToEnumArguments
, wherefoo.rb
contains the following:RuboCop version
The text was updated successfully, but these errors were encountered: