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:
- Open up REPL
- Set variable “a” to value “b”
- Have a try block assign a new value,“b”, to “a”
- Have a finally block print “a”
- See the output is the original assignment,“b”
- print “a” again on the REPL
- 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
22
julia> try
a = 1+1
finally
print(a)
end
22
julia> a
2
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
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, skylake)