From 893ebb69f61e03640b615b19614682ca33eda124 Mon Sep 17 00:00:00 2001 From: Ulf Wiger Date: Thu, 17 Aug 2023 20:43:59 +0200 Subject: [PATCH] Update src/aeserialization.erl with duplicates check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From code review Co-authored-by: Radosław Rowicki <35342116+radrow@users.noreply.github.com> --- src/aeserialization.erl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/aeserialization.erl b/src/aeserialization.erl index 0853e91..11d70a8 100644 --- a/src/aeserialization.erl +++ b/src/aeserialization.erl @@ -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) ->