Skip to content
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

open up arg signature for Hash#slice #7822

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

toregeschliman
Copy link

@toregeschliman toregeschliman commented Apr 10, 2024

Hash#slice has well-defined behavior for arguments that are not keys in the receiving hash: it leaves those keys out of the result object. The return type is still guarantee-able because arguments that don't match the key type will be absent in the result, but the argument type permits anything as input. Common use case for this is passing a nilable argument to a Hash that has typed non-nilable keys; the expected and actual result in the nil case is an empty hash.

Motivation

https://github.com/sorbet/sorbet/pull/7789/files caused multiple lint failures in our codebase on valid Ruby
Addresses #7821

Test plan

Updated the test but leaving this in draft, still debating whether I need an additional assertion to test argument validity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant