From 61cd05efb0d9da46b49316be6343eb323ab5f817 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Mon, 25 Oct 2021 18:57:10 +0200 Subject: [PATCH] break/continue: Stop checking if it's in a loop again This is already checked in the parse_util_detect_errors (and might actually be done in the ast - that's where we check "end") --- src/builtin.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/builtin.cpp b/src/builtin.cpp index 78030a4d8..fcd65957d 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -270,21 +270,6 @@ static maybe_t builtin_break_continue(parser_t &parser, io_streams_t &strea return STATUS_INVALID_ARGS; } - // Paranoia: ensure we have a real loop. - bool has_loop = false; - for (const auto &b : parser.blocks()) { - if (b.type() == block_type_t::while_block || b.type() == block_type_t::for_block) { - has_loop = true; - break; - } - if (b.is_function_call()) break; - } - if (!has_loop) { - wcstring error_message = format_string(_(L"%ls: Not inside of loop\n"), argv[0]); - builtin_print_help(parser, streams, argv[0], &error_message); - return STATUS_CMD_ERROR; - } - // Mark the status in the libdata. parser.libdata().loop_status = is_break ? loop_status_t::breaks : loop_status_t::continues; return STATUS_CMD_OK;