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

RE: Nasty bug in array-element typeset assignments

> > > Yes, recent changes has enabled it.

Commit log does not have article number, but diffs are here:


> Really? So what would it do? Make the whole foo array local or just the
> first element? Clearly neither works.

Probably, intent was to create new local array.

> > Yuk.  Whoever decided on this has got a job on their hands.
> > Typeset is going to get *very* confused.  Each change like this
> multiplies,

The problem is here:

   /* Take arguments literally.  Don't glob */
    while ((asg = getasg(*argv++))) {
        if (!typeset_single(name, asg->name,
                            (Param) (paramtab == realparamtab ?
                                     gethashnode2(paramtab, asg->name) :
                            func, on, off, roff, asg->value, NULL))
            returnval = 1;

We get foo[1]=bar and try to fetch parameter `foo[1]' that does not exist of
course, so later on in typeset_single we believe there is no such parameter.
It means, that we just set element of existing one in

        } else if (PM_TYPE(on) == PM_SCALAR) {
             * This will either complain about bad identifiers, or will set
             * a hash element or array slice.  This once worked by accident,
             * creating a stray parameter along the way via createparam(),
             * now called below in the isident() branch.
            if (!(pm = setsparam(pname, ztrdup(value ? value : ""))))
                return NULL;
            value = NULL;

Later on we obviously change locality of this array in

    if (keeplocal)
        pm->level = keeplocal;

So, this may work assuming that we change getasg() to properly recognize

Note, that this bug affects 4.0.2 as well so we better fix it and issue


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