about summary refs log tree commit diff
path: root/Src/parse.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2009-07-17 20:32:33 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2009-07-17 20:32:33 +0000
commitf43022eec0351406ecdafdf26eeebb488d5a1773 (patch)
tree59cc412ac90c5bffce3feeb285de10776509189b /Src/parse.c
parent351f6541e96e6eca2a55c4519ecc020be82e6ffa (diff)
downloadzsh-f43022eec0351406ecdafdf26eeebb488d5a1773.tar.gz
zsh-f43022eec0351406ecdafdf26eeebb488d5a1773.tar.xz
zsh-f43022eec0351406ecdafdf26eeebb488d5a1773.zip
users/14240: assignment before a function definition is an error
Diffstat (limited to 'Src/parse.c')
-rw-r--r--Src/parse.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Src/parse.c b/Src/parse.c
index 89ef68688..105312f6e 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -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 (;;) {
@@ -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;
 
@@ -1606,6 +1607,7 @@ par_simple(int *complex, int nr)
 		YYERROR(oecused);
 	    incmdpos = oldcmdpos;
 	    isnull = 0;
+	    assignments = 1;
 	} else
 	    break;
 	zshlex();
@@ -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;