Do not parse closures when allow_anonymous_fn is false.

This commit is contained in:
Stephen Chung
2020-08-22 11:08:27 +08:00
parent 24610688d3
commit 0b04d05afe
4 changed files with 84 additions and 3 deletions

View File

@@ -1862,7 +1862,7 @@ fn parse_unary(
}
// | ...
#[cfg(not(feature = "no_function"))]
Token::Pipe | Token::Or => {
Token::Pipe | Token::Or if settings.allow_anonymous_fn => {
let mut new_state = ParseState::new(
state.engine,
#[cfg(not(feature = "unchecked"))]
@@ -3353,6 +3353,8 @@ impl Engine {
};
let expr = parse_expr(input, &mut state, &mut functions, settings)?;
assert!(functions.is_empty());
match input.peek().unwrap() {
(Token::EOF, _) => (),
// Return error if the expression doesn't end