From bcaaec80457193544a5e783ba7356acf0243cc2e Mon Sep 17 00:00:00 2001 From: Ayrton Chilibeck Date: Fri, 31 Jul 2026 10:17:21 -0400 Subject: [PATCH] fix(gazprea): iterators are non-mutable within the iteree --- gazprea/spec/expressions.rst | 7 +++++-- gazprea/spec/statements.rst | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gazprea/spec/expressions.rst b/gazprea/spec/expressions.rst index bde026d..7d4ac7f 100644 --- a/gazprea/spec/expressions.rst +++ b/gazprea/spec/expressions.rst @@ -144,8 +144,11 @@ instance: This is true for domain expressions within generators as well. -Iterator variables can be assigned to and re-declared within the enclosed iterator loop. -The variable is re-initialized according to the expression each iteration. +An iterator variable is a fresh *constant* binding in each iteration: +assigning to it is an error, but a declaration inside the loop body may +shadow it, exactly as in any other nested scope. The shadowing declaration +does not affect the iteration; the iterator is re-bound from the domain at +the start of each iteration. :: diff --git a/gazprea/spec/statements.rst b/gazprea/spec/statements.rst index 9116a7d..cf8f155 100644 --- a/gazprea/spec/statements.rst +++ b/gazprea/spec/statements.rst @@ -359,8 +359,10 @@ Array ranges can also be used instead: i -> std_output; } -The domain is evaluated once during the first iteration of the loop. Each iteration -defines a constant domain variable from it's respective index. For instance: +The domain is evaluated once during the first iteration of the loop. Each +iteration defines a constant domain variable from its respective index; +the variable cannot be assigned to, though it may be shadowed by an inner +declaration (see :ref:`ssec:expressions_dom_expr`). For instance: ::