Re: Hiding specials, and namerefs
Bart Schaefer <[email protected]> Tue, 21 Jul 2026 21:18:31 -0700
| Newsgroups | gmane.comp.shells.zsh.devel |
|---|---|
| Message-ID | <CAH+w=7bVtQunfVqFhJrJPGaY8B+kM9YFnt_NK8h9FFVuMDqkcg@mail.gmail.com> |
Answering some of my own questions, asking new ones ...
On Tue, Jul 21, 2026 at 4:51=E2=80=AFPM Bart Schaefer <schaefer@brasslanter=
n.com> 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.