It’s because mydict is a non-const global variable:
julia> mydict = Dict([("A", 1), ("B", 2)])
Dict{String, Int64} with 2 entries:
"B" => 2
"A" => 1
julia> mydictlookup(mykey) = mydict[mykey]
mydictlookup (generic function with 1 method)
julia> mydictlookup("A")
1
julia> mydict = [1, 2]
2-element Vector{Int64}:
1
2
julia> mydictlookup("A")
ERROR: ArgumentError: invalid index: "A" of type String
Stacktrace:
[1] to_index(i::String)
@ Base ./indices.jl:300
[2] to_index(A::Vector{Int64}, i::String)
@ Base ./indices.jl:277
[3] to_indices
@ ./indices.jl:333 [inlined]
[4] to_indices
@ ./indices.jl:325 [inlined]
[5] getindex(A::Vector{Int64}, I::String)
@ Base ./abstractarray.jl:1170
[6] mydictlookup(mykey::String)
@ Main ./REPL[2]:1
[7] top-level scope
@ REPL[5]:1
julia> mydictlookup(1)
1