From: kazuki@... Date: 2021-01-30T06:51:07+00:00 Subject: [ruby-core:102317] [Ruby master Bug#17595] [Pattern Matching] deconstruct_keys with zero patterns supplies nil for keys argument Issue #17595 has been updated by ktsj (Kazuki Tsujimoto). Status changed from Open to Rejected It is intentional behavior, so I close this ticket. * When `**rest` is used in the pattern, `nil` is passed as a `keys` value. * `{}` is equivalent to `{**rest} if rest.empty?` ---------------------------------------- Bug #17595: [Pattern Matching] deconstruct_keys with zero patterns supplies nil for keys argument https://bugs.ruby-lang.org/issues/17595#change-90171 * Author: baweaver (Brandon Weaver) * Status: Rejected * Priority: Normal * ruby -v: 3.0.0 * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- Example: ```ruby Test = Struct.new(:a, :b) do def deconstruct_keys(ks) p ks: ks to_h.slice(*ks) end end # => Test Test.new(1,2) in {} # {:ks=>nil} # => true ``` As users may call `Array` methods against the `keys` argument I consider this a potential bug that it returns `nil` for no supplied arguments. **Proposed Patch**: Pass an empty array instead to maintain interface consistency. -- https://bugs.ruby-lang.org/ Unsubscribe: