Skip to content

Commit

Permalink
users/14240: assignment before a function definition is an error
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Stephenson committed Jul 17, 2009
1 parent 351f654 commit f43022e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2009-07-17 Peter Stephenson <p.w.stephenson@ntlworld.com>

* users/14240: Src/parse.c: assignment before a function
definition should be an error, in common with other complex
functions and as documented.

2009-07-14 Eric Blake <ebb9@byu.net>

* Eric Blake: 27151: Src/builtin.c: Fix // handling in cd for
Expand Down Expand Up @@ -11991,5 +11997,5 @@

*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
* $Revision: 1.4741 $
* $Revision: 1.4742 $
*****************************************************
8 changes: 7 additions & 1 deletion Src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ static int
par_simple(int *complex, int nr)
{
int oecused = ecused, isnull = 1, r, argc = 0, p, isfunc = 0, sr = 0;
int c = *complex, nrediradd;
int c = *complex, nrediradd, assignments = 0;

r = ecused;
for (;;) {
Expand Down Expand Up @@ -1586,6 +1586,7 @@ par_simple(int *complex, int nr)
ecstr(name);
ecstr(str);
isnull = 0;
assignments = 1;
} else if (tok == ENVARRAY) {
int oldcmdpos = incmdpos, n, type2;

Expand All @@ -1606,6 +1607,7 @@ par_simple(int *complex, int nr)
YYERROR(oecused);
incmdpos = oldcmdpos;
isnull = 0;
assignments = 1;
} else
break;
zshlex();
Expand Down Expand Up @@ -1667,8 +1669,12 @@ par_simple(int *complex, int nr)
zlong oldlineno = lineno;
int onp, so, oecssub = ecssub;

/* Error if too many function definitions at once */
if (!isset(MULTIFUNCDEF) && argc > 1)
YYERROR(oecused);
/* Error if preceding assignments */
if (assignments)
YYERROR(oecused);

*complex = c;
lineno = 0;
Expand Down

0 comments on commit f43022e

Please sign in to comment.