for 2.0, make try/catch/else/finally scopeless? #48434
Labels
breaking
This change will break code
speculative
Whether the change will be implemented is speculative
Milestone
There's been a number of complaints over the years about the fact that each clause of a try/catch/else/finally construct introduces new local scope. This means that if you assign something in the try clause it won't be visible afterwards. But moreover, it won't be visible in the catch, else or finally blocks. The lack of visibility in catch block is and after the whole try construct is somewhat justifiable since we don't want to by default leave undefined variables (although it is easy enough to do with something like
if cond(); x = 1; end
. Perhaps it would be simpler and easier if the whole try construct didn't introduce any local scopes? Similar to how if/else doesn't. Just a thought. Reference example issue: #46928.The text was updated successfully, but these errors were encountered: