From: keystonelemur@... Date: 2021-01-30T06:10:37+00:00 Subject: [ruby-core:102315] [Ruby master Bug#17595] [Pattern Matching] deconstruct_keys with zero patterns supplies nil for keys argument Issue #17595 has been reported by baweaver (Brandon Weaver). ---------------------------------------- Bug #17595: [Pattern Matching] deconstruct_keys with zero patterns supplies nil for keys argument https://bugs.ruby-lang.org/issues/17595 * Author: baweaver (Brandon Weaver) * Status: Open * 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: