From 4ecd46a2e8e425eada02e4bfd698a5482ee8498e Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 19 Nov 2019 16:10:46 +0100 Subject: [PATCH] Clarify scoping with for loops. --- docs/yul.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/yul.rst b/docs/yul.rst index ae8eb1f9e..d0a09d3a5 100644 --- a/docs/yul.rst +++ b/docs/yul.rst @@ -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.