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

PATCH: Remove bogus PM_LOCAL from call to resolve_nameref in setscope



A bogus PM_LOCAL flag in the call to resolve_nameref in setscope prevents the detection of some self references including hidden references.

Example

typeset -n ref1

typeset -n ref2=ref1

() {

  typeset -n ref3=ref2

  typeset ref2=foo

  ref1=ref3

}


Current output

Expected output

<none>

(anon):3: ref3: invalid self reference


The following patch fixes the issue:


Philippe

diff --git a/Src/params.c b/Src/params.c
index 7b515515e..d0f177fa5 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -6375,8 +6375,6 @@ setscope(Param pm)
 	stop.name = "";
 	stop.value.scalar = NULL;
 	stop.flags = PM_NAMEREF;
-	if (locallevel && !(pm->node.flags & PM_UPPER))
-	    stop.flags |= PM_LOCAL;
 	dont_queue_signals();	/* Prevent unkillable loops */
 	basepm = (Param)resolve_nameref(pm, &stop);
 	restore_queue_signals(q);
diff --git a/Test/K01nameref.ztst b/Test/K01nameref.ztst
index 54f0aaf68..566794583 100644
--- a/Test/K01nameref.ztst
+++ b/Test/K01nameref.ztst
@@ -1179,4 +1179,14 @@ F:previously this could create an infinite recursion and crash
 >typeset PS1=zz
 *?*
 
+ typeset -n ref1
+ typeset -n ref2=ref1
+ () {
+   typeset -n ref3=ref2
+   typeset ref2=foo
+   ref1=ref3
+ }
+1:self reference chain including a hidden reference
+?(anon):3: ref3: invalid self reference
+
 %clean


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