Syntax error in an array expression

I ran the following code A = rand(2,3); A[1, 2 +1 ] and I got this error ERROR: syntax: missing separator in array expression. Same error with i=2; A[1, i +1], which is how I came across this. Of course, A[1,2+1] works without issues. I was just wondering if this is supposed to happen. Thanks.

Hi @vvjn,
I believe this is intended. Allowing it might be dangerous because
you might just have forgotten a , instead of wanting to add something.
In that case this could be a silent error.

julia> [1, 2 +2]
ERROR: syntax: missing separator in array expression

julia> [1, 2+2]
2-element Array{Int64,1}:
 1
 4

julia> [1, 2, +2]
3-element Array{Int64,1}:
 1
 2
 2

Okay, sounds good. I thought it was odd since 2 +1 works outside the array syntax.

Yes, unfortunately array syntax ([...]) is one of the few places where whitespace has special syntactic significance.