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

Re: [BUG] zsh/param/private scoping error



On 10/3/21, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Wed, Sep 1, 2021 at 10:35 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
> wrote:
>>
>> Something else has changed since the implementation of private, I
>> think, because this is not what I expected:
>>
>> top () { private foo=top; mid }
>> mid () { typeset -g foo=middle; bot }
>> bot () { print $foo }
>> functions -t top
>
> The attached patch addresses this, producing the output I expected:
>
> +top:0> private foo=top
> +top:0> mid
> +mid:0> typeset -g foo=middle
> +mid:0> bot
> +bot:0> print middle
> middle
>
> It also improves the error message in the event that a typeset
> attempts to change the scope or properties of a private parameter.
>
>> Even
>> without private, "typeset -g" only reaches as far upwards as the most
>> recent local declaration of the name.
>
> A documentation patch to better explain this is included.  As a bonus,
> there's also an explanation of why some parameters do not appear in
> "typeset -p" output.

+private parameters cannot be reliably be reloaded.  This also applies

This sentence has an extra "be".

-- 
Mikael Magnusson




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