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

Re: A solution to fix hidden references in reference chains



(Sorry, focus glitch caused that to be sent in mid-edit.)

On Tue, Feb 17, 2026 at 1:51 PM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>
> Here is an updated patch obtained after rebasing onto the latest head.

Tell me if I'm reading this implementation correctly.

scoperefs is a C array of LinkList pointers.  It will always be as
large as the greatest locallevel (deepest nested scope) in which a
nameref has pointed to a nested parameter, during the lifetime of the
shell.  Therefore there may be NULL (and/or empty list) elements
scattered throughout scoperefs.

Each element of scoperefs is a linked list of named references (Param
pointers) that need to be re-scoped when that locallevel is exited.

Since a given element of scoperefs can only be referenced on the way
down or back up the call stack, maybe a linked list of linked lists
would be preferable?

In the comments you say
> "Param" instances get reused when variables with
> the same name are redefined in the same scope

That would never apply to a parameter in a surrounding scope (it would
always become the pm->old of the new parameter in the nested scope).
In what circumstances, then, does the base of a given parameter need
to be reset more than once to different values?  Does one of the
"Transitive references" tests in K01 cover such a circumstance?




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