mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 14:52:55 +00:00
Let the ordering operators also work on strings
E.g. ‘"foo" < "bar"’ now works.
This commit is contained in:
parent
3d77b28eac
commit
8e74c0bfd1
@ -183,8 +183,8 @@ static void prim_genericClosure(EvalState & state, Value * * args, Value & v)
|
|||||||
list<Value> res;
|
list<Value> res;
|
||||||
set<Value, CompareValues> doneKeys; // !!! use Value *?
|
set<Value, CompareValues> doneKeys; // !!! use Value *?
|
||||||
while (!workSet.empty()) {
|
while (!workSet.empty()) {
|
||||||
Value * e = *(workSet.begin());
|
Value * e = *(workSet.begin());
|
||||||
workSet.pop_front();
|
workSet.pop_front();
|
||||||
|
|
||||||
state.forceAttrs(*e);
|
state.forceAttrs(*e);
|
||||||
|
|
||||||
@ -1032,7 +1032,10 @@ static void prim_div(EvalState & state, Value * * args, Value & v)
|
|||||||
|
|
||||||
static void prim_lessThan(EvalState & state, Value * * args, Value & v)
|
static void prim_lessThan(EvalState & state, Value * * args, Value & v)
|
||||||
{
|
{
|
||||||
mkBool(v, state.forceInt(*args[0]) < state.forceInt(*args[1]));
|
state.forceValue(*args[0]);
|
||||||
|
state.forceValue(*args[1]);
|
||||||
|
CompareValues comp;
|
||||||
|
mkBool(v, comp(*args[0], *args[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
2185
|
2188
|
||||||
|
@ -50,6 +50,11 @@ let {
|
|||||||
(if 2 > 1 == 1 < 2 then 1 else err)
|
(if 2 > 1 == 1 < 2 then 1 else err)
|
||||||
(if 1 + 2 * 3 >= 7 then 1 else err)
|
(if 1 + 2 * 3 >= 7 then 1 else err)
|
||||||
(if 1 + 2 * 3 < 7 then err else 1)
|
(if 1 + 2 * 3 < 7 then err else 1)
|
||||||
|
|
||||||
|
# Not integer, but so what.
|
||||||
|
(if "aa" < "ab" then 1 else err)
|
||||||
|
(if "aa" < "aa" then err else 1)
|
||||||
|
(if "foo" < "foobar" then 1 else err)
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user