I think all of the stuff here is fixed in the latest devel snapshot, though there is definitely weirdness if you run the assignments as a typeset command. I hadn't even tried the ref4 case, which gives the weirdest results when used with typeset/declare: https://groups.google.com/forum/#!topic/gnu.bash.bug/Z-lf3KEnZ34