Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG] zsh/param/private scoping error
- X-seq: zsh-workers 49356
- From: Marlon Richert <marlon.richert@xxxxxxxxx>
- To: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [BUG] zsh/param/private scoping error
- Date: Wed, 1 Sep 2021 19:21:25 +0300
- Archived-at: <https://zsh.org/workers/49356>
- In-reply-to: <20210901140958.GD27958@tarpaulin.shahaf.local2>
- List-id: <zsh-workers.zsh.org>
- References: <CAHLkEDtxe8wtOZ8dWC2tUdhQBpSZtKjGc7MrzJYBJ9oPdjP9Pw@mail.gmail.com> <20210901140958.GD27958@tarpaulin.shahaf.local2>
On Wed, Sep 1, 2021 at 5:10 PM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
> Marlon Richert wrote on Wed, Sep 01, 2021 at 14:49:58 +0300:
> > 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.
>
> Makes sense to me. A regression test (one with the 'F' flag) would be
> welcome, if you've got spare tuits.
I was about to create one in V10private.ztst, when I noticed it
appears to exist already on lines 230 - 250. :)
typeset -A hash_test=(top level)
() {
local -Pa array_test=(in function)
local -PA hash_test=($array_test)
() {
print X ${(kv)hash_test}
hash_test=(even deeper)
{
array_test+=(${(kv)hash_test})
} always {
print ${array_test-array_test not set} ${(t)array_test}
}
}
print Y ${(kv)hash_test} Z $array_test
}
print ${(kv)hash_test} ${(t)array_test}
1:privates are not visible in anonymous functions, part 3
>X top level
>array_test not set
?(anon):4: array_test: attempt to assign private in nested scope
F:future revision will create a global with this assignment
Messages sorted by:
Reverse Date,
Date,
Thread,
Author