fix: implication operator (->)
This commit is contained in:
@@ -351,7 +351,7 @@ impl<Ctx: CodegenContext> Compile<Ctx> for BinOp {
|
||||
Impl => {
|
||||
code!(
|
||||
buf, ctx;
|
||||
"Nix.withContext(\"while evaluating the || operator\"," self.span ",()=>(Nix.forceBool(" lhs ")||Nix.forceBool(" rhs ")))"
|
||||
"Nix.withContext(\"while evaluating the -> operator\"," self.span ",()=>(!Nix.forceBool(" lhs ")||Nix.forceBool(" rhs ")))"
|
||||
);
|
||||
}
|
||||
PipeL => {
|
||||
|
||||
@@ -117,3 +117,28 @@ fn select_with_default_nested_lazy() {
|
||||
fn select_with_default_fallback() {
|
||||
assert_eq!(eval("{ a = 1; }.b or 999"), Value::Int(999));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn implication_false_false() {
|
||||
assert_eq!(eval("false -> false"), Value::Bool(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn implication_false_true() {
|
||||
assert_eq!(eval("false -> true"), Value::Bool(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn implication_true_false() {
|
||||
assert_eq!(eval("true -> false"), Value::Bool(false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn implication_true_true() {
|
||||
assert_eq!(eval("true -> true"), Value::Bool(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn implication_short_circuit() {
|
||||
assert_eq!(eval("false -> (1 / 0)"), Value::Bool(true));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user