Function names capturing as external variables bug

This commit is contained in:
Ilya Lakhin 2020-08-08 17:55:58 +07:00
parent b604ea3e93
commit 45d021c7ef

View File

@ -1635,6 +1635,11 @@ fn parse_primary(
Token::CharConstant(c) => Expr::CharConstant(Box::new((c, settings.pos))), Token::CharConstant(c) => Expr::CharConstant(Box::new((c, settings.pos))),
Token::StringConstant(s) => Expr::StringConstant(Box::new((s.into(), settings.pos))), Token::StringConstant(s) => Expr::StringConstant(Box::new((s.into(), settings.pos))),
Token::Identifier(s) => { Token::Identifier(s) => {
// prevents capturing of the function call
#[cfg(not(feature = "no_closure"))]
if *next_token == Token::LeftParen || *next_token == Token::Bang {
state.allow_capture = false;
}
let index = state.access_var(&s, settings.pos); let index = state.access_var(&s, settings.pos);
Expr::Variable(Box::new(((s, settings.pos), None, 0, index))) Expr::Variable(Box::new(((s, settings.pos), None, 0, index)))
} }