Merge pull request #8445 from ethereum/fixTryCatch

Fix scoping following try/catch.
This commit is contained in:
chriseth 2020-03-09 14:59:24 +01:00 committed by GitHub
commit 88c41f5e9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 0 deletions

View File

@ -12,6 +12,7 @@ Compiler Features:
Bugfixes:
* Inheritance: Fix incorrect error on calling unimplemented base functions.
* isoltest: Added new keyword `wei` to express function value in semantic tests
* Reference Resolver: Fix scoping issue following try/catch statements.
* Standard-JSON-Interface: Fix a bug related to empty filenames and imports.
* SMTChecker: Fix internal errors when analysing tuples.
* Yul AST Import: correctly import blocks as statements, switch statements and string literals.

View File

@ -67,6 +67,22 @@ void ReferencesResolver::endVisit(Block const& _block)
m_resolver.setScope(_block.scope());
}
bool ReferencesResolver::visit(TryCatchClause const& _tryCatchClause)
{
if (!m_resolveInsideCode)
return false;
m_resolver.setScope(&_tryCatchClause);
return true;
}
void ReferencesResolver::endVisit(TryCatchClause const& _tryCatchClause)
{
if (!m_resolveInsideCode)
return;
m_resolver.setScope(_tryCatchClause.scope());
}
bool ReferencesResolver::visit(ForStatement const& _for)
{
if (!m_resolveInsideCode)

View File

@ -70,6 +70,8 @@ private:
bool visit(Block const& _block) override;
void endVisit(Block const& _block) override;
bool visit(TryCatchClause const& _tryCatchClause) override;
void endVisit(TryCatchClause const& _tryCatchClause) override;
bool visit(ForStatement const& _for) override;
void endVisit(ForStatement const& _for) override;
void endVisit(VariableDeclarationStatement const& _varDeclStatement) override;

View File

@ -0,0 +1,10 @@
contract Test {
// This checks a scoping error,
// the variable "a" was not visible
// at the assignment.
function test(address _ext) external {
try Test(_ext).test(_ext) {} catch {}
uint a = 1;
a = 3;
}
}