"declare" when used in a function acts like "local", and creates a variable with scope local to that function. So does "declare -r". But "readonly", which is otherwise the same as "declare -r", creates variables with global scope.
Is this intended? Tested with 2.05b, 3.something, and 4.2.20.