Update src/aeserialization.erl with duplicates check

From code review

Co-authored-by: Radosław Rowicki <35342116+radrow@users.noreply.github.com>
This commit is contained in:
Ulf Wiger 2023-08-17 20:43:59 +02:00 committed by GitHub
parent 05c4f87619
commit 893ebb69f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -129,6 +129,7 @@ decode_field(#{items := Items}, List) when length(List) =:= length(Items) ->
Zipped = lists:zip(Items, List),
lists:foldl(
fun({{K, Type}, V}, Map) ->
maps:is_key(K, Map) andalso error(badarg, duplicate_field),
Map#{ K => decode_field(Type, V) }
end, #{}, Zipped);
decode_field(Type, List) when length(List) =:= tuple_size(Type) ->