You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the documentation of the map generator the KeyPattern can be any pattern. However, using a partial record as pattern doesn't work. However, using the same record pattern in a list generator works as expected.
To Reproduce
Sample code:
-record(foo, {f1, f2}).
t4() ->
List = [{#foo{f1 = X, f2 = X*2}, X} || X <- lists:seq(1, 10)],
FilteredList = [V || {#foo{f1 = M}, V} <- List, M rem 2 =:= 0],
io:format("List Test~nList: ~0p~nFiltered: ~0p~n", [List, FilteredList]),
Map = maps:from_list(List),
FilteredMap = [V || #foo{f1 = N} := V <- Map, N rem 2 =:= 0],
io:format("~nMap Test~nMap: ~0p~nFiltered: ~0p~n", [Map, FilteredMap]),
ok.
Describe the bug
According to the documentation of the map generator the
KeyPattern
can be any pattern. However, using a partial record as pattern doesn't work. However, using the same record pattern in a list generator works as expected.To Reproduce
Sample code:
Resulting output:
When the
KeyPattern
is modified to#foo{f1 = N} = _ := V
, it works. However, there is nothing in the documentation that would explain why that is so.Expected behavior
The
Filtered
list should be the same for the list and map example.Affected versions
OTP 26.1.2: Erlang/OTP 26 [erts-14.1.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit:ns]
The text was updated successfully, but these errors were encountered: