That’s just not how Julia’s parser works. Whether something is a symbol or a range expression needs to be decided at parse time, where no information about types is available. This would also be fairly fragile — an example where this breaks down is DataFrames.jl, where DataFrames can be indexed with symbols as well as ranges. I would also suggest reading this post by Stefan, since this behavior is now fairly established in Julia and found to work quite well, so it is very unlikely this is going to change.
6 Likes