Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: anonymous functions, full patch



On Tue, 1 Jul 2008 19:43:49 +0200
"Mikael Magnusson" <mikachu@xxxxxxxxx> wrote:
> I played a bit with this to see what works and what doesn't, and I
> came across this non-working syntax (which is also obviously useless,
> but still):
> 
> () a=b
> zsh: parse error near `\n'

This isn't new, you always got this, even if there was a function name
in front.  It's there because there's a test that a function body
consists of sufficiently complex code that it can't be simplified to
executing a single shell structure.  As this can, you get the error.

That seems an odd thing to test at this point in the code, and the more
I look at it the more I think it should be testing the return value of
the function instead...  It's odd this hasn't shown up before, but I
suppose there was a reasonable chance of a parse error occurring before
the parameter had been set to 1.

Index: Src/parse.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/parse.c,v
retrieving revision 1.69
diff -u -r1.69 parse.c
--- Src/parse.c	14 Mar 2008 11:40:59 -0000	1.69
+++ Src/parse.c	1 Jul 2008 18:29:00 -0000
@@ -1687,8 +1687,7 @@
 		sl = ecadd(0);
 		pl = ecadd(WCB_PIPE(WC_PIPE_END, 0));
 
-		par_cmd(&c);
-		if (!c) {
+		if (!par_cmd(&c)) {
 		    cmdpop();
 		    YYERROR(oecused);
 		}

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author