From a5dd96558f906e95e7fe6de30c2358333e254dc4 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Thu, 1 Mar 2018 11:45:41 -0800 Subject: [PATCH] Remove special && and || error detection Soon these will no longer be errors. --- src/fish_tests.cpp | 7 +------ src/parse_constants.h | 11 +---------- src/parse_tree.cpp | 33 ++------------------------------- 3 files changed, 4 insertions(+), 47 deletions(-) diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index 29a01ba5f..3f0cb0b8f 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -3624,9 +3624,6 @@ static void test_new_parser_errors() { {L"case", parse_error_unbalancing_case}, {L"if true ; case ; end", parse_error_unbalancing_case}, - - {L"foo || bar", parse_error_double_pipe}, - {L"foo && bar", parse_error_double_background}, }; for (size_t i = 0; i < sizeof tests / sizeof *tests; i++) { @@ -3742,9 +3739,7 @@ static void test_error_messages() { {L"echo \"foo\"$\"bar\"", ERROR_NO_VAR_NAME}, {L"echo foo $ bar", ERROR_NO_VAR_NAME}, {L"echo foo$(foo)bar", ERROR_BAD_VAR_SUBCOMMAND1}, - {L"echo \"foo$(foo)bar\"", ERROR_BAD_VAR_SUBCOMMAND1}, - {L"echo foo || echo bar", ERROR_BAD_OR}, - {L"echo foo && echo bar", ERROR_BAD_AND}}; + {L"echo \"foo$(foo)bar\"", ERROR_BAD_VAR_SUBCOMMAND1}}; parse_error_list_t errors; for (size_t i = 0; i < sizeof error_tests / sizeof *error_tests; i++) { diff --git a/src/parse_constants.h b/src/parse_constants.h index b8e43fe0c..044f549e0 100644 --- a/src/parse_constants.h +++ b/src/parse_constants.h @@ -183,10 +183,7 @@ enum parse_error_code_t { parse_error_unbalancing_end, // end outside of block parse_error_unbalancing_else, // else outside of if - parse_error_unbalancing_case, // case outside of switch - - parse_error_double_pipe, // foo || bar, has special error message - parse_error_double_background // foo && bar, has special error message + parse_error_unbalancing_case // case outside of switch }; enum { PARSER_TEST_ERROR = 1, PARSER_TEST_INCOMPLETE = 2 }; @@ -289,12 +286,6 @@ void parse_error_offset_source_start(parse_error_list_t *errors, size_t amt); /// Error issued on $. #define ERROR_NO_VAR_NAME _(L"Expected a variable name after this $.") -/// Error on ||. -#define ERROR_BAD_OR _(L"Unsupported use of '||'. In fish, please use 'COMMAND; or COMMAND'.") - -/// Error on &&. -#define ERROR_BAD_AND _(L"Unsupported use of '&&'. In fish, please use 'COMMAND; and COMMAND'.") - /// Error on foo=bar. #define ERROR_BAD_EQUALS_IN_COMMAND5 \ _(L"Unsupported use of '='. To run '%ls' with a modified environment, please use 'env " \ diff --git a/src/parse_tree.cpp b/src/parse_tree.cpp index a284b346d..48094446b 100644 --- a/src/parse_tree.cpp +++ b/src/parse_tree.cpp @@ -674,37 +674,8 @@ void parse_ll_t::parse_error_failed_production(struct parse_stack_element_t &sta parse_token_t token) { fatal_errored = true; if (this->should_generate_error_messages) { - bool done = false; - - // Check for ||. - if (token.type == parse_token_type_pipe && token.source_start > 0) { - // Here we wanted a statement and instead got a pipe. See if this is a double pipe: foo - // || bar. If so, we have a special error message. - const parse_node_t *prev_pipe = nodes.find_node_matching_source_location( - parse_token_type_pipe, token.source_start - 1, NULL); - if (prev_pipe != NULL) { - // The pipe of the previous job abuts our current token. So we have ||. - this->parse_error(token, parse_error_double_pipe, ERROR_BAD_OR); - done = true; - } - } - - // Check for &&. - if (!done && token.type == parse_token_type_background && token.source_start > 0) { - // Check to see if there was a previous token_background. - const parse_node_t *prev_background = nodes.find_node_matching_source_location( - parse_token_type_background, token.source_start - 1, NULL); - if (prev_background != NULL) { - // We have &&. - this->parse_error(token, parse_error_double_background, ERROR_BAD_AND); - done = true; - } - } - - if (!done) { - const wcstring expected = stack_elem.user_presentable_description(); - this->parse_error_unexpected_token(expected.c_str(), token); - } + const wcstring expected = stack_elem.user_presentable_description(); + this->parse_error_unexpected_token(expected.c_str(), token); } }