Allow stacking ! operators.
This commit is contained in:
parent
049f472ac9
commit
c245fe88fd
@ -17,9 +17,10 @@ license = "MIT OR Apache-2.0"
|
|||||||
include = [
|
include = [
|
||||||
"**/*.rs",
|
"**/*.rs",
|
||||||
"scripts/*.rhai",
|
"scripts/*.rhai",
|
||||||
|
"**/*.md",
|
||||||
"Cargo.toml"
|
"Cargo.toml"
|
||||||
]
|
]
|
||||||
keywords = [ "scripting" ]
|
keywords = [ "scripting", "scripting-engine", "scripting language", "embedded" ]
|
||||||
categories = [ "no-std", "embedded", "wasm", "parser-implementations" ]
|
categories = [ "no-std", "embedded", "wasm", "parser-implementations" ]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -19,6 +19,7 @@ Bug fixes
|
|||||||
|
|
||||||
* Parameters passed to plugin module functions were sometimes erroneously consumed. This is now fixed.
|
* Parameters passed to plugin module functions were sometimes erroneously consumed. This is now fixed.
|
||||||
* Fixes compilation errors in `metadata` feature build.
|
* Fixes compilation errors in `metadata` feature build.
|
||||||
|
* Stacking `!` operators now work properly.
|
||||||
|
|
||||||
New features
|
New features
|
||||||
------------
|
------------
|
||||||
|
@ -1338,7 +1338,7 @@ fn parse_unary(
|
|||||||
Token::Bang => {
|
Token::Bang => {
|
||||||
let pos = eat_token(input, Token::Bang);
|
let pos = eat_token(input, Token::Bang);
|
||||||
let mut args = StaticVec::new();
|
let mut args = StaticVec::new();
|
||||||
let expr = parse_primary(input, state, lib, settings.level_up())?;
|
let expr = parse_unary(input, state, lib, settings.level_up())?;
|
||||||
args.push(expr);
|
args.push(expr);
|
||||||
|
|
||||||
let op = "!";
|
let op = "!";
|
||||||
|
@ -12,8 +12,7 @@ fn test_not() -> Result<(), Box<EvalAltResult>> {
|
|||||||
#[cfg(not(feature = "no_function"))]
|
#[cfg(not(feature = "no_function"))]
|
||||||
assert_eq!(engine.eval::<bool>("fn not(x) { !x } not(false)")?, true);
|
assert_eq!(engine.eval::<bool>("fn not(x) { !x } not(false)")?, true);
|
||||||
|
|
||||||
// TODO - do we allow stacking unary operators directly? e.g '!!!!!!!true'
|
assert_eq!(engine.eval::<bool>("!!!!true")?, true);
|
||||||
assert_eq!(engine.eval::<bool>("!(!(!(!(true))))")?, true);
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user