Add a description of values which cause a bad type the failure.
svn path=/nixpkgs/trunk/; revision=16054
This commit is contained in:
parent
c69010d6eb
commit
dd50af4923
@ -43,6 +43,8 @@ rec {
|
||||
traceCall2 = n : f : a : b : let t = n2 : x : traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a) (t "arg 2" b));
|
||||
traceCall3 = n : f : a : b : c : let t = n2 : x : traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a) (t "arg 2" b) (t "arg 3" c));
|
||||
|
||||
traceValIfNot = c: x:
|
||||
if c x then true else trace (showVal x) false;
|
||||
|
||||
/* Evaluate a set of tests. A test is an attribute set {expr,
|
||||
expected}, denoting an expression and its expected result. The
|
||||
|
@ -163,37 +163,37 @@ rec {
|
||||
|
||||
bool = mkOptionType {
|
||||
name = "boolean";
|
||||
check = builtins.isBool;
|
||||
check = lib.traceValIfNot builtins.isBool;
|
||||
merge = fold lib.or false;
|
||||
};
|
||||
|
||||
int = mkOptionType {
|
||||
name = "integer";
|
||||
check = builtins.isInt;
|
||||
check = lib.traceValIfNot builtins.isInt;
|
||||
};
|
||||
|
||||
string = mkOptionType {
|
||||
name = "string";
|
||||
check = x: builtins ? isString -> builtins.isString x;
|
||||
check = lib.traceValIfNot (x: builtins ? isString -> builtins.isString x);
|
||||
merge = lib.concatStrings;
|
||||
};
|
||||
|
||||
attrs = mkOptionType {
|
||||
name = "attribute set";
|
||||
check = builtins.isAttrs;
|
||||
check = lib.traceValIfNot builtins.isAttrs;
|
||||
merge = fold lib.mergeAttrs {};
|
||||
};
|
||||
|
||||
# derivation is a reserved keyword.
|
||||
package = mkOptionType {
|
||||
name = "derivation";
|
||||
check = x: builtins.isAttrs x && x ? outPath;
|
||||
check = lib.traceValIfNot isDerivation;
|
||||
};
|
||||
|
||||
|
||||
list = elemType: mkOptionType {
|
||||
name = "list of ${elemType.name}s";
|
||||
check = value: isList value && all elemType.check value;
|
||||
check = value: lib.traceValIfNot isList value && all elemType.check value;
|
||||
merge = concatLists;
|
||||
iter = f: path: list: map (elemType.iter f (path + ".*")) list;
|
||||
fold = op: nul: list: lib.fold (e: l: elemType.fold op l e) nul list;
|
||||
@ -203,7 +203,7 @@ rec {
|
||||
|
||||
attrsOf = elemType: mkOptionType {
|
||||
name = "attribute set of ${elemType}s";
|
||||
check = x: builtins.isAttrs x
|
||||
check = x: lib.traceValIfNot builtins.isAttrs x
|
||||
&& fold (e: v: v && elemType.check e) true (lib.attrValues x);
|
||||
merge = fold lib.mergeAttrs {};
|
||||
iter = f: path: set: lib.mapAttrs (name: elemType.iter f (path + "." + name)) set;
|
||||
@ -230,7 +230,7 @@ rec {
|
||||
|
||||
optionSet = mkOptionType {
|
||||
name = "option set";
|
||||
check = x: builtins.isAttrs x;
|
||||
check = x: lib.traceValIfNot builtins.isAttrs x;
|
||||
hasOptions = true;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user