Parsing of :

Is this handling of : by Julia parser intentional?

julia> x[:
       a]
ERROR: ArgumentError: invalid index: a
Stacktrace:
 [1] getindex(::Array{Int64,1}, ::Symbol) at .\abstractarray.jl:883

julia> x[:
       ]
ERROR: syntax: invalid syntax: "]"

julia> function f():
       a
       end
f (generic function with 1 method)

julia> f()
:a:

julia> try :
       a
       end
:a 

The reason why it might be important is that the last two examples (defining function and try block) can mislead people switching from Python, who probably have muscle memory to add : at the end of such expressions (see e.g. Julia: invalid assignment location when creating function to subset dataframe - Stack Overflow).

Cf
https://github.com/JuliaLang/julia/pull/20265
probably just needs attention.

1 Like

Thanks. I have just checked on master that the issue is fixed.

1 Like