diff options
author | chriseth <chris@ethereum.org> | 2018-02-09 23:53:52 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-02-27 19:17:25 +0800 |
commit | e6d48bb72a82e2b3140d5a98da2961e401430a25 (patch) | |
tree | 174e49e2eddf6b92fe2fd24960af928e2b9444a8 /libsolidity/ast/AST.cpp | |
parent | 5f20129e65f5b8b714189145d177067152a21ac1 (diff) | |
download | dexon-solidity-e6d48bb72a82e2b3140d5a98da2961e401430a25.tar.gz dexon-solidity-e6d48bb72a82e2b3140d5a98da2961e401430a25.tar.zst dexon-solidity-e6d48bb72a82e2b3140d5a98da2961e401430a25.zip |
Blocks and for loops can be scopes.
Diffstat (limited to 'libsolidity/ast/AST.cpp')
-rw-r--r-- | libsolidity/ast/AST.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index af007908..60a15aeb 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -415,6 +415,15 @@ bool VariableDeclaration::isLValue() const return !isExternalCallableParameter() && !m_isConstant; } +bool VariableDeclaration::isLocalVariable() const +{ + auto s = scope(); + return + dynamic_cast<CallableDeclaration const*>(s) || + dynamic_cast<Block const*>(s) || + dynamic_cast<ForStatement const*>(s); +} + bool VariableDeclaration::isCallableParameter() const { auto const* callable = dynamic_cast<CallableDeclaration const*>(scope()); @@ -460,8 +469,7 @@ bool VariableDeclaration::isExternalCallableParameter() const bool VariableDeclaration::canHaveAutoType() const { - auto const* callable = dynamic_cast<CallableDeclaration const*>(scope()); - return (!!callable && !isCallableParameter()); + return isLocalVariable() && !isCallableParameter(); } TypePointer VariableDeclaration::type() const |