Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: All the way up or current scope
On Tue, May 13, 2025 at 5:09 AM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>
> One thing that would help me for creating that side-by-side comparisons is the ability to test -u0 references with a real implementation rather than simulating them in my head.
I still plan to respond to the discussion when I have a chance, but
for the sake of argument, I believe if you apply this patch, then
"setopt warn_nested_var" will (instead of warning) change the behavior
to scope "typeset -n" references in the way you suggest.
diff --git a/Src/params.c b/Src/params.c
index 7b515515e..680547938 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -6430,9 +6430,13 @@ setscope(Param pm)
zerr("%s: global reference cannot refer to local variable",
pm->node.nam);
unsetparam_pm(pm, 0, 1);
- } else if (isset(WARNNESTEDVAR))
+ } else if (isset(WARNNESTEDVAR)) {
+ pm->base = pm->level;
+ /*
zwarn("reference %s in enclosing scope set to local
variable %s",
pm->node.nam, refname);
+ */
+ }
}
if (refname && upscope(pm, pm->base) == pm &&
strcmp(pm->node.nam, refname) == 0) {
Messages sorted by:
Reverse Date,
Date,
Thread,
Author