Open
Description
I am wondering why code:
function f()
const x = "aaa"
x = 4
return x
end
println(f())
executes and prints 4 without any warning or error, while
const x = "aaa"
x = 4
println(x)
raises:
ERROR: invalid redefinition of constant x
Similarly:
function f()
const x = "aaa"
x = "bbb"
return x
end
println(f())
prints bbb without warning, while:
const x = "aaa"
x = "bbb"
println(x)
prints bbb, but with warning:
Warning: redefining constant x
I think behavior of constants should be consistent in global and function scopes.
My Julia version:
Julia Version 0.2.0
Commit 05c6461 (2013-11-16 23:44 UTC)
Platform Info:
System: Windows (x86_64-w64-mingw32)
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY)
LAPACK: libopenblas
LIBM: libopenlibm