Expected Behavior for Varible Scoping with try/finally?

Hello, I am learning Julia and was reading through the docs for Essentials. I ran into behavior that did not seem to match what I expected.
Steps to reproduce:

  1. Open up REPL
  2. Set variable “a” to value “b”
  3. Have a try block assign a new value,“b”, to “a”
  4. Have a finally block print “a”
  5. See the output is the original assignment,“b”
  6. print “a” again on the REPL
  7. Observe the new, correct, value, “c”

Finally appeared to be executing before variable “a” was assigned a new value. I know it is a fairly silly use of the try/finally keywords, and I am certain there is probably an std out reasoning for the issue, but it was strange enough that I decided to post about it.

Behavior does not appear in a basic begin/end version, which makes total sense.

Output from my REPL Session

julia> a = 22

julia> try
       a = 1+1

julia> a

julia> versioninfo()
Julia Version 1.5.0
Commit 96786e22cc (2020-08-01 23:44 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)

I’m a fool. Haha, The 22 is a result of the print and result both being 2 with no space. Well, after playing around with New Values, it turns out I am a looney and the try/finally blocks work just fine.

1 Like