Add ‘seq’ primop
This commit is contained in:
parent
eff120d1b9
commit
a54c263402
|
@ -383,6 +383,15 @@ static void prim_getEnv(EvalState & state, const Pos & pos, Value * * args, Valu
|
|||
}
|
||||
|
||||
|
||||
/* Evaluate the first argument, then return the second argument. */
|
||||
void prim_seq(EvalState & state, const Pos & pos, Value * * args, Value & v)
|
||||
{
|
||||
state.forceValue(*args[0]);
|
||||
state.forceValue(*args[1]);
|
||||
v = *args[1];
|
||||
}
|
||||
|
||||
|
||||
/* Evaluate the first expression and print it on standard error. Then
|
||||
return the second expression. Useful for debugging. */
|
||||
static void prim_trace(EvalState & state, const Pos & pos, Value * * args, Value & v)
|
||||
|
@ -1424,6 +1433,9 @@ void EvalState::createBaseEnv()
|
|||
addPrimOp("__tryEval", 1, prim_tryEval);
|
||||
addPrimOp("__getEnv", 1, prim_getEnv);
|
||||
|
||||
// Strictness
|
||||
addPrimOp("__seq", 2, prim_seq);
|
||||
|
||||
// Debugging
|
||||
addPrimOp("__trace", 2, prim_trace);
|
||||
addPrimOp("__gcCanary", 1, prim_gcCanary);
|
||||
|
|
1
tests/lang/eval-fail-seq.nix
Normal file
1
tests/lang/eval-fail-seq.nix
Normal file
|
@ -0,0 +1 @@
|
|||
builtins.seq (abort "foo") 2
|
1
tests/lang/eval-okay-seq.exp
Normal file
1
tests/lang/eval-okay-seq.exp
Normal file
|
@ -0,0 +1 @@
|
|||
2
|
1
tests/lang/eval-okay-seq.nix
Normal file
1
tests/lang/eval-okay-seq.nix
Normal file
|
@ -0,0 +1 @@
|
|||
builtins.seq 1 2
|
Loading…
Reference in a new issue