Also allow unclosed quotes in some places

See #7693
This commit is contained in:
Johannes Altmanninger 2021-02-09 22:36:27 +01:00
parent 38b95defbd
commit 86707378cc
2 changed files with 8 additions and 2 deletions

View File

@ -1112,7 +1112,8 @@ class ast_t::populator_t {
if (!token.allows_token(peek_token().type)) {
const auto &peek = peek_token();
if ((flags_ & parse_flag_leave_unterminated) &&
peek.tok_error == tokenizer_error_t::unterminated_subshell) {
(peek.tok_error == tokenizer_error_t::unterminated_quote ||
peek.tok_error == tokenizer_error_t::unterminated_subshell)) {
return;
}
@ -1140,7 +1141,8 @@ class ast_t::populator_t {
const auto &peek = peek_token();
if ((flags_ & parse_flag_leave_unterminated) &&
peek.tok_error == tokenizer_error_t::unterminated_subshell) {
(peek.tok_error == tokenizer_error_t::unterminated_quote ||
peek.tok_error == tokenizer_error_t::unterminated_subshell)) {
return;
}

View File

@ -4798,6 +4798,10 @@ static void test_new_parser_ad_hoc() {
errors.clear();
ast = ast_t::parse(L"for x in (", parse_flag_leave_unterminated, &errors);
do_test(errors.size() == 1 && errors.at(0).code == parse_error_tokenizer_unterminated_subshell);
errors.clear();
ast = ast_t::parse(L"begin; echo '", parse_flag_leave_unterminated, &errors);
do_test(errors.size() == 1 && errors.at(0).code == parse_error_tokenizer_unterminated_quote);
}
static void test_new_parser_errors() {