While I was looking into implementing the solution for hidden references, I found this
call to upscope, which had to be wrong because it applies "base", a property of the referent, to the reference. Here is an example that fails because of this:
typeset -n ref=var1
() {
typeset -n ref=var2
ref=RESET
typeset -p ref var1 var2
}
typeset -p ref var1 var2
Output:
(anon):typeset:3: no such variable: var2
typeset -n ref=var2
typeset -g var1=''
test.zsh:typeset:7: no such variable: var2
typeset -n ref=var1
typeset var1=''
Expected output:
(anon):typeset:3: no such variable: var1
typeset -n ref=var2
typeset -g var2=RESET
test.zsh:typeset:7: no such variable: var1
typeset -n ref=var1
typeset var2=RESET
The attached tentative patch removes the invalid call to upscope and changes the stop parameter passed to resolve_nameref. It now looks similar to the one found in
setscope but the flags are different. I don't fully understand how the stop parameter works, so better double-check this.
The patch changes the behavior of one regression test. The new behavior looks correct to me.
Philippe