git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commitef8996f15ea2dd5aace0f61f9ab03f3dfa3d4975 authorSilvan Mosberger <infinisil@icloud.com> dateFri 9 Mar 2018, 13:41 (9 years ago) parent85b5fc7
1 file changed+1−1
lib/types.nix+1−1
lib/types.nix+1−1
@@ -420,7 +420,7 @@ rec {
420420 mkOptionType rec {
421421 name = "coercedTo";
422422 description = "${finalType.description} or ${coercedType.description}";
423− check = x: finalType.check x || coercedType.check x;
423+ check = x: finalType.check x || (coercedType.check x && finalType.check (coerceFunc x));
424424 merge = loc: defs:
425425 let
426426 coerceVal = val: