How to create a local read-only variable in bash?

How do I create both local and declare -r (read-only) variable in bash? If I do: function x { declare -r var=val } Then I simply get a global var that is read-only If I do: function x {