···515 # yield a value computed from the definitions
516 value = if opt ? apply then opt.apply res.mergedValue else res.mergedValue;
517518- # Issue deprecation warnings recursively over all nested types of the
519- # given type. But don't recurse if a type with the same name was already
520- # visited before in order to prevent infinite recursion. So this only
521- # warns once per type name.
522- # Returns the new set of visited type names
523- recursiveWarn = visited: type:
524- let
525- maybeWarn = warnIf (type.deprecationMessage != null)
526- "The type `types.${type.name}' of option `${showOption loc}' defined in ${showFiles opt.declarations} is deprecated. ${type.deprecationMessage}";
527- in
528- if visited ? ${type.name} then visited
529- else lib.foldl' recursiveWarn (maybeWarn visited // { ${type.name} = null; }) (lib.attrValues type.nestedTypes);
530531- in builtins.seq (recursiveWarn {} opt.type) opt //
532 { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
533 inherit (res.defsFinal') highestPrio;
534 definitions = map (def: def.value) res.defsFinal;
···515 # yield a value computed from the definitions
516 value = if opt ? apply then opt.apply res.mergedValue else res.mergedValue;
517518+ warnDeprecation =
519+ warnIf (opt.type.deprecationMessage != null)
520+ "The type `types.${opt.type.name}' of option `${showOption loc}' defined in ${showFiles opt.declarations} is deprecated. ${opt.type.deprecationMessage}";
000000000521522+ in warnDeprecation opt //
523 { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
524 inherit (res.defsFinal') highestPrio;
525 definitions = map (def: def.value) res.defsFinal;
-6
lib/tests/modules.sh
···272checkConfigOutput "b a" config.result ./functionTo/list-order.nix
273checkConfigOutput "a c" config.result ./functionTo/merging-attrs.nix
274275-## Type deprecation
276-checkConfigError 'The type `types.simple'\'' of option `simple'\'' defined in .* is deprecated. simple shall not be used' config.simple ./type-deprecation.nix
277-checkConfigError 'The type `types.infinite'\'' of option `infinite'\'' defined in .* is deprecated. infinite shall not be used' config.infinite ./type-deprecation.nix
278-checkConfigError 'The type `types.left'\'' of option `nested'\'' defined in .* is deprecated. left shall not be used' config.nested ./type-deprecation.nix
279-checkConfigError 'The type `types.right'\'' of option `nested'\'' defined in .* is deprecated. right shall not be used' config.nested ./type-deprecation.nix
280-281cat <<EOF
282====== module tests ======
283$pass Pass