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

[BUG] zsh/param/private scoping error



The following two functions are normally equivalent:

() { typeset -g tst }
() { tst= }

Both result in a global variable 'tst' being created. However when the
second function is called from a function that happens to declare a
private variable with the same name, it no longer creates a global
variable but instead aborts with an error:

% () { private tst; () { tst= } }
(anon):1: tst: attempt to assign private in nested scope
%

This is not how one would expect private variables to behave. Inside
the inner function, the private variable should be completely out of
scope and the `tst=` statement should result in the creation of a
global variable.

Note that the error above does not happens when there already exists a
global variable with the same name:

% typeset -g tst
% () { private tst; () { tst= } }
%




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