The introduction of the paragraph on For statements with range clause fails to mention the range over function:

A "for" statement with a "range" clause iterates through all entries of an array, slice, string or map, values received on a channel, or integer values from zero to an upper limit [Go 1.22]. [...]

and also

The expression on the right in the "range" clause is called the range expression, its core type must be an array, pointer to an array, slice, string, map, channel permitting receive operations, or an integer.

Comment From: gabyhelp

Similar Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Comment From: gazerro

Note also that the statement

If the range expression is a channel or integer, at most one iteration variable is permitted, otherwise there may be up to two.

is not accurate, as func(func() bool) does not allow iteration variables, and func(func(V) bool) allows at most one iteration variable.

Comment From: griesemer

Thanks for this. Update forthcoming.

Comment From: gopherbot

Change https://go.dev/cl/592595 mentions this issue: spec: adjust for-range prose to include iterator functions where missing