The definitive section is Primary Expressions:
Primary expressions are the operands for unary and binary expressions.
It goes on to define primary expressions, but basically, this includes slice expressions, meaning that the slice expression a[0]
is the operand for the unary operator *
. A special case was made for pointers to arrays (see below).
According to Address Operators:
For an operand x of type T, the address operation &x generates a pointer of type *T to x. The operand must be addressable, that is, either a variable, pointer indirection, or slice indexing operation; or a field selector of an addressable struct operand; or an array indexing operation of an addressable array. As an exception to the addressability requirement, x may also be a (possibly parenthesized) composite literal. If the evaluation of x would cause a run-time panic, then the evaluation of &x does too.
For an operand x of pointer type *T, the pointer indirection *x denotes the variable of type T pointed to by x. If x is nil, an attempt to evaluate *x will cause a run-time panic.
This implies, but does not explicitly state, that a slice indexing expression or field selector expression to the right of the pointer indirection operator is evaluated as a whole before the indirection is evaluated.
Also, pointer indirection (*x
) is an operator, specifically, an Address Operator. The slice index reference is not an operator but rather an Index Expression.
Also note that:
For a of pointer to array type:
a[x]
is shorthand for (*a)[x]
Though the same cannot be said of pointers to slice types.