addCheck
lib.types.addCheck
Docs pulled from | This Revision | about 1 hour ago
Augment the given type with an additional type check function.
This function has some broken behavior see: #396021 Fixing is not trivial, we appreciate any help!
Noogle detected
Implementation
The following is the current implementation of this function.
addCheck =
elemType: check:
if elemType.merge ? v2 then
elemType
// {
check = x: elemType.check x && check x;
merge = {
__functor =
self: loc: defs:
(self.v2 { inherit loc defs; }).value;
v2 =
{ loc, defs }:
let
orig = elemType.merge.v2 { inherit loc defs; };
headError' = if orig.headError != null then orig.headError else checkDefsForError check loc defs;
in
orig
// {
headError = headError';
};
};
}
else
elemType
// {
check = x: elemType.check x && check x;
};