From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: PATCH: break: more completely enumerate loop types we are not in
Date: Sat, 25 May 2019 21:29:10 +0200 [thread overview]
Message-ID: <20190525192910.30730-1-mikachu@gmail.com> (raw)
---
Src/builtin.c | 4 ++--
Test/A07control.ztst | 9 ++++++++-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/Src/builtin.c b/Src/builtin.c
index 2453f82c08..8c17475f1b 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5590,13 +5590,13 @@ bin_break(char *name, char **argv, UNUSED(Options ops), int func)
switch (func) {
case BIN_CONTINUE:
if (!loops) { /* continue is only permitted in loops */
- zerrnam(name, "not in while, until, select, or repeat loop");
+ zerrnam(name, "not in for, while, until, select, or repeat loop");
return 1;
}
contflag = 1; /* FALLTHROUGH */
case BIN_BREAK:
if (!loops) { /* break is only permitted in loops */
- zerrnam(name, "not in while, until, select, or repeat loop");
+ zerrnam(name, "not in for, while, until, select, or repeat loop");
return 1;
}
breaks = nump ? minimum(num,loops) : 1;
diff --git a/Test/A07control.ztst b/Test/A07control.ztst
index b1a2487324..a3a82a68d1 100644
--- a/Test/A07control.ztst
+++ b/Test/A07control.ztst
@@ -23,12 +23,19 @@
>start 255
>255
+ $ZTST_testdir/../Src/zsh -fc 'fn() {
+ break
+ }
+ fn'
+1:break outside loop
+?fn:break:1: not in for, while, until, select, or repeat loop
+
$ZTST_testdir/../Src/zsh -fc 'fn() {
continue
}
fn'
1:continue outside loop
-?fn:continue:1: not in while, until, select, or repeat loop
+?fn:continue:1: not in for, while, until, select, or repeat loop
for outer in 0 1 2 3; do
print outer $outer
--
2.15.1
reply other threads:[~2019-05-25 19:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190525192910.30730-1-mikachu@gmail.com \
--to=mikachu@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).