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

Re: Hiding specials, and namerefs



Answering some of my own questions, asking new ones ...

On Tue, Jul 21, 2026 at 4:51 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> B02typeset.ztst
> (eval):typeset:3: SRANDOM: can't change type of autoloaded parameter
> Was testing: Global -h variable doesn't hide autoload variable
>
> I think this one exemplifies the change, the use of -h shouldn't be a
> silent no-op.  Thoughts?

Clarification here.  The restriction on -h only applies when
attempting to change the attribute ("type" in the error message is
wrong, I've corrected) on an existing parameter.   That applies to
this test because it uses -gh.  If the -g is removed, a new local is
being created and that is definitely allowed to hide the special from
the surrounding scope.  I think I have that working.

New question:  Should there be just a warning in this case, or an
actual error?  An error would change the behavior.

While testing this I discovered that the same (silent no-op) behavior
applies to "typeset -gn" for specials, and for autoloads we get e.g.
this:

% typeset -gn SRANDOM
zsh: invalid variable name: zsh/random

I'll see if I can track that down.

> Why does it ever make sense to apply -h to a global?  What's the point
> of this test?

I still have this question.




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