Why is there parsing ambiguity in accessing a list in postgres?

Viewed 28

In postgres it allows doing:

SELECT (ARRAY[1,2])[1] AS a

But it does not allow:

SELECT ARRAY[1,2][1] AS a

This seems a bit arbitrary to me that it would be ambiguous when not including parens around the array literal, what would be an example where this would be ambiguous? Most languages have a construct of a direct array access, so curious why it's considered ambiguous in PG.

0 Answers
Related