The following function seems to work well because the value it returns is of type Int8
function abc()
#local x::Int8 # in a local declaration
x::Int8 = 10 # as the left-hand side of an assignment
x
end
x = abc()
println(x)
print(typeof(x))
10
Int8
However, if I remove the x inside the abc() function, the result changes, and now it is of type Int64.
function abc()
#local x::Int8 # in a local declaration
x::Int8 = 10 # as the left-hand side of an assignment
end
x = abc()
println(x)
print(typeof(x))
10
Int64
In my opinion, this makes no sense, because in both cases, the variable “x” is returned, and it should always be of type Int8.
I suppose I am missing something, but I do not know what it is. Any hints?