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

Re: PATCH: Fix nameref errors exposed by Philippe's tests



On Mon, May 5, 2025 at 3:49 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Mon, May 5, 2025 at 1:52 PM Philippe Altherr
> <philippe.altherr@xxxxxxxxx> wrote:
> >
> > I don't understand why the results for nr-test -u {5..10} keep referring to "g".
>
> Hm.  It's not looking one level above the current scope, it's looking
> one level above the parameter currently in scope.

To fix that scoping issue:

diff --git a/Src/params.c b/Src/params.c
index cb1f6d4b0..e6fb7fcd0 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -6404,14 +6404,14 @@ setscope(Param pm)
         } else if (!pm->base) {
         pm->base = basepm->level;
         if ((pm->node.flags & PM_UPPER) &&
-            (basepm = upscope(basepm, -(pm->level))))
+            (basepm = upscope(basepm, -(locallevel-1))))
             pm->base = basepm->level;
         }
     } else if (pm->base < locallevel && refname &&
            (basepm = (Param)getparamnode(realparamtab, refname))) {
         pm->base = basepm->level;
         if ((pm->node.flags & PM_UPPER) &&
-        (basepm = upscope(basepm, -(pm->level))))
+        (basepm = upscope(basepm, -(locallevel-1))))
         pm->base = basepm->level;
     }
     if (pm->base > pm->level) {




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