Add logical xor operator (#7242)

We already have the binary `bit-xor` and the shortcircuiting logical
`or`(`||`) and `and`(`&&`).
This introduces `xor` as a compact form for both brevity and clarity.
You can express the operation through `not`/`and`/`or` with a slight
risk of introducing bugs through typos.

Operator precedence

`and` > `xor` > `or`

Added logic and precedence tests.
This commit is contained in:
Stefan Holderbach
2022-11-26 17:02:37 +01:00
committed by GitHub
parent 3e76ed9122
commit 2ccb91dc6a
9 changed files with 57 additions and 1 deletions

View File

@ -404,6 +404,10 @@ pub fn eval_expression(
lhs.or(op_span, &rhs, expr.span)
}
}
Boolean::Xor => {
let rhs = eval_expression(engine_state, stack, rhs)?;
lhs.xor(op_span, &rhs, expr.span)
}
}
}
Operator::Math(math) => {