On Mon, Oct 20, 2025, 11:36 Chet Ramey <[email protected]> wrote:
>
> On 10/15/25 12:19 PM, Grisha Levit wrote:
> > While a compound assignment to a dangling nameref removes the
> > nameref attribute:
> >
> > $ f() { local -n x; x=(); local -p; }; f
> > bash: warning: x: removing nameref attribute
> > declare -a x=()
> >
> > the same does not happen when using `local' to perform compound
> > assignment or to set the array or assoc attribute on a dangling
> > nameref:
>
> Thanks for the report. I don't get the segmentation fault, but converting
> an unset nameref into an array or an assoc variable should definitely
> remove the nameref attribute.
Looks like circular namerefs might need something similar as well:
f() {
local -n x; local -p x
local -A x; local -p x
(local x=(z))
}
x=x f
bash: local: x: not found
bash: warning: x: circular name reference
bash: warning: x: circular name reference
declare -Anx x=()
Segmentation fault ( local x=(z) )