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.

Changed files
+1 -1
lib
+1 -1
lib/types.nix
···
mkOptionType rec {
name = "coercedTo";
description = "${finalType.description} or ${coercedType.description}";
-
check = x: finalType.check x || coercedType.check x;
merge = loc: defs:
let
coerceVal = val:
···
mkOptionType rec {
name = "coercedTo";
description = "${finalType.description} or ${coercedType.description}";
+
check = x: finalType.check x || (coercedType.check x && finalType.check (coerceFunc x));
merge = loc: defs:
let
coerceVal = val: