Which version are you on? With the 1.1 Julia (
julia> versioninfo()
Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-6650U CPU @ 2.20GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
JULIA_EDITOR = "C:\Users\PetrKrysl\AppData\Local\atom\app-1.37.0\atom.exe" -a
JULIA_NUM_THREADS = 2
) I get the same result as you. I think the scoping rules (New scope solution - #53 by StefanKarpinski) may be in effect.
In the first case, the variable is read, and the globally visible x
is printed.
In the second case, the variable is written into (it is incremented), and therefore it is assumed to be a local variable, and since the local x
does not exist, an error is reported.