git.iko.soy/typeable/nixpkgs
on master help sign in
Improve types.listOf error message

If an option value is not a list, you now get The option value `bla' in `file.nix' is not a list. rather than value is a string while a list was expected, at .../nixpkgs/lib/lists.nix:49:56

commitb056948c005c642c68220c4d45a6273eeafc36c2 authorEelco Dolstra <eelco.dolstra@logicblox.com> dateWed 25 May 2016, 11:02 (11 years ago) parent32bed83
1 file changed+11−7
lib/types.nix+11−7
lib/types.nix+11−7
@@ -114,13 +114,17 @@ rec {
114114 name = "list of ${elemType.name}s";
115115 check = isList;
116116 merge = loc: defs:
117− map (x: x.value) (filter (x: x ? value) (concatLists (imap (n: def: imap (m: def':
118− (mergeDefinitions
119− (loc ++ ["[definition ${toString n}-entry ${toString m}]"])
120− elemType
121− [{ inherit (def) file; value = def'; }]
122− ).optionalValue
123− ) def.value) defs)));
117+ map (x: x.value) (filter (x: x ? value) (concatLists (imap (n: def:
118+ if isList def.value then
119+ imap (m: def':
120+ (mergeDefinitions
121+ (loc ++ ["[definition ${toString n}-entry ${toString m}]"])
122+ elemType
123+ [{ inherit (def) file; value = def'; }]
124+ ).optionalValue
125+ ) def.value
126+ else
127+ throw "The option value `${showOption loc}' in `${def.file}' is not a list.") defs)));
124128 getSubOptions = prefix: elemType.getSubOptions (prefix ++ ["*"]);
125129 getSubModules = elemType.getSubModules;
126130 substSubModules = m: listOf (elemType.substSubModules m);