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

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



On 9/1/21, Marlon Richert <marlon.richert@xxxxxxxxx> wrote:
> On Wed, Sep 1, 2021 at 7:03 PM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>> If private parameters
>> are only compatible with code that runs without warnings under setopt
>> WARN_CREATE_GLOBAL, then we should document this.
>
> That would largely defeat the purpose of private variables, wouldn't it? :)

Ah, I misinterpreted one of the examples, I thought that this would
work as you expect:
() { private foo; () { typeset -g foo=bar } }
(while this wouldn't:
() { private foo; () { foo=bar } }
)

But in both cases it is an error (although only the latter prints a
message and aborts execution), and foo is not set globally.

In fact a typeset -g is needed on the global level before the function
using private is called, which seems impossible for the innermost
function to enforce.

-- 
Mikael Magnusson




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