diff options
| author | Bart Schaefer <schaefer@zsh.org> | 2025-05-09 16:38:28 -0700 |
|---|---|---|
| committer | Bart Schaefer <schaefer@zsh.org> | 2025-05-09 16:38:28 -0700 |
| commit | abd541e18c1a8c311834ed85d9abd5f3fd27495f (patch) | |
| tree | 0c4bce8a4860c827e9197e2ee3fab1f3200c67a6 /Src | |
| parent | 53532: mark --enable-zsh-mem as deprecated. (diff) | |
| download | zsh-abd541e18c1a8c311834ed85d9abd5f3fd27495f.tar zsh-abd541e18c1a8c311834ed85d9abd5f3fd27495f.tar.gz zsh-abd541e18c1a8c311834ed85d9abd5f3fd27495f.tar.bz2 zsh-abd541e18c1a8c311834ed85d9abd5f3fd27495f.tar.lz zsh-abd541e18c1a8c311834ed85d9abd5f3fd27495f.tar.xz zsh-abd541e18c1a8c311834ed85d9abd5f3fd27495f.tar.zst zsh-abd541e18c1a8c311834ed85d9abd5f3fd27495f.zip | |
53568: fix additional problems with reference scoping, update documentation
Scope exits could miss some scope updates in named reference chains.
References declared -u behave like any other reference upon scope exit.
Diffstat (limited to 'Src')
| -rw-r--r-- | Src/params.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Src/params.c b/Src/params.c index e6fb7fcd0..b4179a4f4 100644 --- a/Src/params.c +++ b/Src/params.c @@ -5828,7 +5828,9 @@ static void scanendscope(HashNode hn, UNUSED(int flags)) { Param pm = (Param)hn; + Param hidden = NULL; if (pm->level > locallevel) { + hidden = pm->old; if ((pm->node.flags & (PM_SPECIAL|PM_REMOVABLE)) == PM_SPECIAL) { /* * Removable specials are normal in that they can be removed @@ -5891,9 +5893,15 @@ scanendscope(HashNode hn, UNUSED(int flags)) export_param(pm); } else unsetparam_pm(pm, 0, 0); - } else if ((pm->node.flags & PM_NAMEREF) && - pm->base > pm->level && pm->base > locallevel) + } + if (hidden) + pm = hidden; + if (pm && (pm->node.flags & PM_NAMEREF) && + pm->base >= pm->level && pm->base >= locallevel) { pm->base = locallevel; + if (pm->level < locallevel && (pm->node.flags & PM_UPPER)) + pm->node.flags &= ~PM_UPPER; + } } @@ -6404,14 +6412,14 @@ setscope(Param pm) } else if (!pm->base) { pm->base = basepm->level; if ((pm->node.flags & PM_UPPER) && - (basepm = upscope(basepm, -(locallevel-1)))) + (basepm = upscope(basepm, -locallevel))) 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, -(locallevel-1)))) + (basepm = upscope(basepm, -locallevel))) pm->base = basepm->level; } if (pm->base > pm->level) { |
