Skip to content

Commit 3c871d1

Browse files
committed
Doc: clarify behavior of "anyrange" pseudo-type.
I noticed that we completely failed to document the restriction that an "anyrange" result type has to be inferred from an "anyrange" input. The docs also were less clear than they could be about the relationship between "anyrange" and "anyarray". It's been like this all along, so back-patch.
1 parent d67d724 commit 3c871d1

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

doc/src/sgml/extend.sgml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,12 @@
225225
<type>anyarray</type> positions must be an array whose elements are
226226
the same type appearing in the <type>anyelement</type> positions.
227227
Similarly, if there are positions declared <type>anyrange</type>
228-
and others declared <type>anyelement</type>, the actual range type in
229-
the <type>anyrange</type> positions must be a range whose subtype is
230-
the same type appearing in the <type>anyelement</type> positions.
231-
<type>anynonarray</> is treated exactly the same as <type>anyelement</>,
228+
and others declared <type>anyelement</type> or <type>anyarray</type>,
229+
the actual range type in the <type>anyrange</type> positions must be a
230+
range whose subtype is the same type appearing in
231+
the <type>anyelement</type> positions and the same as the element type
232+
of the <type>anyarray</type> positions.
233+
<type>anynonarray</type> is treated exactly the same as <type>anyelement</type>,
232234
but adds the additional constraint that the actual type must not be
233235
an array type.
234236
<type>anyenum</> is treated exactly the same as <type>anyelement</>,
@@ -258,6 +260,17 @@
258260
will only accept arrays of enum types.
259261
</para>
260262

263+
<para>
264+
In most cases, the parser can infer the actual data type for a
265+
polymorphic result type from arguments that are of a different
266+
polymorphic type; for example <type>anyarray</type> can be deduced
267+
from <type>anyelement</type> or vice versa. The exception is that a
268+
polymorphic result of type <type>anyrange</type> requires an argument
269+
of type <type>anyrange</type>; it cannot be deduced
270+
from <type>anyarray</type> or <type>anyelement</type> arguments. This
271+
is because there could be multiple range types with the same subtype.
272+
</para>
273+
261274
<para>
262275
Note that <type>anynonarray</> and <type>anyenum</> do not represent
263276
separate type variables; they are the same type as

0 commit comments

Comments
 (0)