From ef8996f15ea2dd5aace0f61f9ab03f3dfa3d4975 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 9 Mar 2018 13:41:55 +0100 Subject: [PATCH] lib/types: Fix coercedTo check Without this change (coercedTo str toInt int).check "foo" would evaluate to true, even though (coercedTo str toInt int).merge {} [{ value = "foo"; }] will throw an error because "foo" can't be coerced to an int. --- lib/types.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/types.nix b/lib/types.nix index a334db5c7247..45b0ae5042ce 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -420,7 +420,7 @@ rec { mkOptionType rec { name = "coercedTo"; description = "${finalType.description} or ${coercedType.description}"; - check = x: finalType.check x || coercedType.check x; + check = x: finalType.check x || (coercedType.check x && finalType.check (coerceFunc x)); merge = loc: defs: let coerceVal = val: