lib.types.defaultTypeMerge: Fix for functors with no wrapped attr

Downstream types that want to use `lib.types.defaultTypeMerge` must include
`wrapped` even though it is deprecated or the internal
`wrappedDeprecationMessage`. This is caused by accessing the
`wrapped` attr in `lib.types.defaultTypeMerge`. The logic should first check
if the attr exists and then if it does check if it is null.
This commit is contained in:
Timothy Gallion 2026-01-01 15:17:53 -05:00
commit f32c37b88c
No known key found for this signature in database
3 changed files with 39 additions and 2 deletions

View file

@ -158,8 +158,11 @@ rec {
assert (f'.payload != null) == (f.payload != null);
f.payload != null;
hasWrapped =
assert (f'.wrapped != null) == (f.wrapped != null);
f.wrapped != null;
let
hasWrappedNonNull = set: set ? "wrapped" && set.wrapped != null;
in
assert (hasWrappedNonNull f') == (hasWrappedNonNull f);
hasWrappedNonNull f;
typeFromPayload = if mergedPayload == null then null else f.type mergedPayload;
typeFromWrapped = if mergedWrapped == null then null else f.type mergedWrapped;