Skip to content

already assigned associative array elements cannot be used in default assignment of another element of same array #966

Description

@jghub

did not know how to better describe this behaviour (I use this : "${var:=val}" construct for default value assignments in a certain context since it works with set -u if var is not defined yet):

unset x
typeset -A x
x[a]=1
y=${x[a]}
: "${x[b]:=${x[a]}}"
: "${x[c]:=$y}"
print -v x

result:

(
        [a]=1
        [b]=
        [c]=1
)

so x[b] does not pick up the value of x[a] as it should (same with legacy ksh93u+, bash behaves as intended). looks like a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions