Clarify scoping with for loops.

This commit is contained in:
chriseth 2019-11-19 16:10:46 +01:00 committed by GitHub
parent 72ef4242b6
commit 4ecd46a2e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -182,11 +182,17 @@ introduce new identifiers into these scopes.
Identifiers are visible in
the block they are defined in (including all sub-nodes and sub-blocks).
As an exception, identifiers defined in the "init" part of the for-loop
As an exception, identifiers defined directly in the "init" part of the for-loop
(the first block) are visible in all other parts of the for-loop
(but not outside of the loop).
Identifiers declared in the other parts of the for loop respect the regular
syntactical scoping rules.
This means a for-loop of the form ``for { I... } C { P... } { B... }`` is equivalent
to ``{ I... for {} C { P... } { B... } }``.
The parameters and return parameters of functions are visible in the
function body and their names cannot overlap.