Ensure Registry.match/4 works with :_ as key
This commit is contained in:
@@ -534,7 +534,8 @@ defmodule Registry do
|
||||
"""
|
||||
@spec match(registry, key, match_pattern :: atom() | tuple(), guards :: list()) :: [{pid, term}]
|
||||
def match(registry, key, pattern, guards \\ []) when is_atom(registry) and is_list(guards) do
|
||||
spec = [{{key, {:_, pattern}}, guards, [{:element, 2, :"$_"}]}]
|
||||
guards = [{:"=:=", {:element, 1, :"$_"}, {:const, key}} | guards]
|
||||
spec = [{{:_, {:_, pattern}}, guards, [{:element, 2, :"$_"}]}]
|
||||
|
||||
case key_info!(registry) do
|
||||
{:unique, partitions, key_ets} ->
|
||||
|
||||
@@ -69,6 +69,10 @@ defmodule RegistryTest do
|
||||
[{self(), value}]
|
||||
assert Registry.match(registry, "hello", {:"$1", :_, :"$1"}) ==
|
||||
[{self(), value}]
|
||||
assert Registry.match(registry, "hello", :_) ==
|
||||
[{self(), value}]
|
||||
assert Registry.match(registry, :_, :_) ==
|
||||
[]
|
||||
end
|
||||
|
||||
test "supports guard conditions", %{registry: registry} do
|
||||
|
||||
Reference in New Issue
Block a user