1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-30 07:10:58 +02:00

users/14240: assignment before a function definition is an error

This commit is contained in:
Peter Stephenson 2009-07-17 20:32:33 +00:00
parent 351f6541e9
commit f43022eec0
2 changed files with 14 additions and 2 deletions

View file

@ -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> 2009-07-14 Eric Blake <ebb9@byu.net>
* Eric Blake: 27151: Src/builtin.c: Fix // handling in cd for * Eric Blake: 27151: Src/builtin.c: Fix // handling in cd for
@ -11991,5 +11997,5 @@
***************************************************** *****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL * This is used by the shell to define $ZSH_PATCHLEVEL
* $Revision: 1.4741 $ * $Revision: 1.4742 $
***************************************************** *****************************************************

View file

@ -1546,7 +1546,7 @@ static int
par_simple(int *complex, int nr) par_simple(int *complex, int nr)
{ {
int oecused = ecused, isnull = 1, r, argc = 0, p, isfunc = 0, sr = 0; 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; r = ecused;
for (;;) { for (;;) {
@ -1586,6 +1586,7 @@ par_simple(int *complex, int nr)
ecstr(name); ecstr(name);
ecstr(str); ecstr(str);
isnull = 0; isnull = 0;
assignments = 1;
} else if (tok == ENVARRAY) { } else if (tok == ENVARRAY) {
int oldcmdpos = incmdpos, n, type2; int oldcmdpos = incmdpos, n, type2;
@ -1606,6 +1607,7 @@ par_simple(int *complex, int nr)
YYERROR(oecused); YYERROR(oecused);
incmdpos = oldcmdpos; incmdpos = oldcmdpos;
isnull = 0; isnull = 0;
assignments = 1;
} else } else
break; break;
zshlex(); zshlex();
@ -1667,8 +1669,12 @@ par_simple(int *complex, int nr)
zlong oldlineno = lineno; zlong oldlineno = lineno;
int onp, so, oecssub = ecssub; int onp, so, oecssub = ecssub;
/* Error if too many function definitions at once */
if (!isset(MULTIFUNCDEF) && argc > 1) if (!isset(MULTIFUNCDEF) && argc > 1)
YYERROR(oecused); YYERROR(oecused);
/* Error if preceding assignments */
if (assignments)
YYERROR(oecused);
*complex = c; *complex = c;
lineno = 0; lineno = 0;