From 2ec464fc8d49be0dd34e2f3bbc70b2f589d23dbc Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Tue, 21 Nov 2023 13:14:22 +0000 Subject: [PATCH] Don't validate when there's nothing to validate This would otherwise mean that the consumers would have to prepare for e.g. validation of empty list, which can already be done at this level --- src/eon_type.erl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/eon_type.erl b/src/eon_type.erl index 8539e96..2081238 100644 --- a/src/eon_type.erl +++ b/src/eon_type.erl @@ -281,6 +281,8 @@ typecheck(#spec{term=Term0, type=Type, p_have=P_have}) -> eon_type_rec -> Term = ?unlift(check_obj(Term0, Type:decl(Term0, P_have))), case erlang:function_exported(Type, extra_validation, 2) of + true when Term =:= [] -> + Term; true -> case Type:extra_validation(Term, P_have) of ok -> Term;