Re: Hiding specials, and namerefs

Bart Schaefer <[email protected]> Fri, 24 Jul 2026 21:14:04 -0700
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <CAH+w=7Z3tHuUerd+yhvAEz-Yn+_7-gp9XfNnmCq7Oo74HrJCrw@mail.gmail.com>
On Thu, Jul 23, 2026 at 7:12=E2=80=AFPM Philippe Altherr
<[email protected]> wrote:
>
> I was reviewing the code of typeset_single in order to understand how spe=
cial parameters get localized. I still haven't figured this out but I notic=
ed that this condition is most likely missing a PM_NAMEREF.

    else if (usepm || newspecial !=3D NS_NONE) {
    int chflags =3D ((off & pm->node.flags) | (on & ~pm->node.flags)) &
        (PM_INTEGER|PM_EFLOAT|PM_FFLOAT|PM_HASHED|
         PM_ARRAY|PM_TIED|PM_AUTOLOAD);
    /* keep the parameter if just switching between floating types */

Adding PM_NAMEREF there changes only the "remove nameref attribute"
and "add and remove readonly attribute with references" tests in K01
(and not in I think a way we want) and makes no difference to `typeset
-gn SRANDOM`

E.g.:
--- expected
+++ actual
@@ -1 +1 @@
-typeset ptr=3Dvar
+typeset ptr
Test K01nameref.ztst failed: output differs from expected as shown above fo=
r:
 typeset -n ptr=3Dvar
 typeset +n ptr
 typeset -p ptr
Was testing: remove nameref attribute