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

Re: Recursion error and line numbers



Bart Schaefer wrote:
> local foo=(); local bar
> 
> In workers/22495 I wrote:
> 
> > zsh% local
> > local:10: maximum nested function level reached
> > zsh% 

On the two PCs I tried this on (neither particularly antiquated) it
crashed, so the maximum function depth of 4096 isn't limited enough.
How about 1000?  That seems to stop it.

> There are not 10 lines in the function "local", nor are there 50 lines
> when I try the "compinit" test and mysteriously get the error twice:
> 
> zsh% compinit
> local:50: maximum nested function level reached
> local:1: maximum nested function level reached
> zsh% 
> 
> Obviously the recursion depth isn't 1 or 10 or 50 either.  Where is that
> number coming from?  I would have expected "1" in all cases.

It's a subtle effect of line number handling and I haven't quite worked
out why yet.  It seems that in the case in question we haven't quite got
around to setting the line number in the function yet (on any of the
4096 calls).   Compare with:

% local() { :; local bar; }
% local
local: maximum nested function level reached

No line number (0 is suppressed).

% local() { :;             
local bar; }
% local       
local:1: maximum nested function level reached

The 1 you're expecting.

This is obviously a bug but I haven't it traced it.

-- 
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