diff --git a/Src/parse.c b/Src/parse.c index b09c7989a..153633bb1 100644 --- a/Src/parse.c +++ b/Src/parse.c @@ -1525,10 +1525,16 @@ par_while(int *cmplx) incmdpos = 1; while (tok == SEPER) zshlex(); - if (tok == DOLOOP) { + /* + * If the very first thing after "while" is "do", + * ecused has advanced only two positions. This + * is not a valid while-do construction. + */ + if (tok == DOLOOP && (ecused - oecused) > 2) { zshlex(); par_save_list(cmplx); - if (tok != DONE) + /* As above but "do done" is not valid */ + if (tok != DONE || (ecused - oecused) < 8) YYERRORV(oecused); incmdpos = 0; zshlex();