rake
rake copied to clipboard
Fix TaskArguments#deconstruct_keys with keys = nil
This fixes a bug in the initial implementation (#515):
#deconstruct_keys should handle keys == nil, or **rest will be broken.
For example, the normal behavior looks like this:
{a: 1, b: 2, c: 3} => {a:, **rest}
a # => 1
rest # => {b: 2, c: 3}
But without handling keys == nil, we'll get this:
class Example
def initialize(hash) = @hash = hash
def deconstruct_keys(keys) = @hash.slice(*keys)
end
Example.new({a: 1, b: 2, c: 3}) => {a:, **rest}
# !> "#{inspect}: key not found: :a" (NoMatchingPatternKeyError)