From 7b6fd013a473e93f1f9381de19e83c06697af10c Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Thu, 12 May 2016 09:59:29 -0400 Subject: Added origin of scoping rules --- docs/control-structures.rst | 1 + 1 file changed, 1 insertion(+) (limited to 'docs') diff --git a/docs/control-structures.rst b/docs/control-structures.rst index 3e766b5c..0e74c589 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -148,6 +148,7 @@ Scoping and Declarations .. index:: ! scoping, ! declarations In Solidity, a variable declared anywhere within a function will be in scope for the *entire function*, regardless of where it is declared. +This happens because Solidity inherits its scoping rules from JavaScript. This is in contrast to many languages where variables are only scoped where they are declared until the end of the semantic block. As a result, the following code is illegal and cause the compiler to throw an error, `Identifier already declared.`:: -- cgit v1.2.3