zsh-workers
 help / color / mirror / code / Atom feed
* [BUG] zsh/param/private scoping error
@ 2021-09-01 11:49 Marlon Richert
  2021-09-01 14:09 ` Daniel Shahaf
  2021-09-01 14:39 ` Bart Schaefer
  0 siblings, 2 replies; 11+ messages in thread
From: Marlon Richert @ 2021-09-01 11:49 UTC (permalink / raw)
  To: Zsh hackers list

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= } }
%


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-10-04 15:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-01 11:49 [BUG] zsh/param/private scoping error Marlon Richert
2021-09-01 14:09 ` Daniel Shahaf
2021-09-01 16:21   ` Marlon Richert
2021-09-01 14:39 ` Bart Schaefer
2021-09-01 16:03   ` Mikael Magnusson
2021-09-01 16:11     ` Marlon Richert
2021-09-01 17:00       ` Mikael Magnusson
2021-09-01 17:35         ` Bart Schaefer
2021-10-03 21:55           ` Bart Schaefer
2021-10-04  4:54             ` Mikael Magnusson
2021-10-04 15:12               ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).