It works because both instances are local to a function and don't exist outside their own functions.Not true. This: bash -c 'a() { echo "$v"; }; b() { declare -r v=123; a; }; b' Produces this: 123
Moreover, this: bash -c 'a() { v=2; }; b () { v=1; a; echo "$v"; }; b' Produces this: 2