function () {
typeset -nu ref=var
typeset var=inner
ref=outer
echo ref=$ref
}
typeset -p var
Output:
ref=
typeset: no such variable: var
The assignment ref=outer is supposed to create a global variable named var but it can't because there is a local variable with the same name. Shouldn't this print a warning? Something along the line "assignment to named reference referring 'var' failed to create global variable 'var' because of local variable with the same name".
The problem can happen when the user calls a library function of which they have never seen the source code. In that case they may have a very hard time understanding why no variable was created. The warning would give them a clue of what's going on. That specific case and the warning should probably be described in the documentation (which may already be partially the case, I haven't checked). Thanks to the warning plus a web search the user could easlily find that description.
Philippe