From db5f2b415399da9b653e68aa03f23ce661cc5339 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 23 Apr 2024 17:30:02 -0700 Subject: spec: clarify when a range expression is evaluated If the range expression is a numeric constant, the range expression is also not evaluated. Change-Id: I97201e5c136d3d1a87ed1500b19b7199b30bc9ff Reviewed-on: https://go-review.googlesource.com/c/go/+/581298 Reviewed-by: Robert Griesemer Reviewed-by: Ian Lance Taylor TryBot-Bypass: Robert Griesemer Auto-Submit: Robert Griesemer --- doc/go_spec.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/go_spec.html b/doc/go_spec.html index 0fd12bf4b5..f5069f62d6 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -6644,8 +6644,8 @@ the range clause is equivalent to the same clause without that identifier.

The range expression x is evaluated once before beginning the loop, -with one exception: if at most one iteration variable is present and -len(x) is constant, +with one exception: if at most one iteration variable is present and x or +len(x) is constant, the range expression is not evaluated.

-- cgit v1.2.3-54-g00ecf