mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #8445 from ethereum/fixTryCatch
Fix scoping following try/catch.
This commit is contained in:
commit
88c41f5e9d
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
10
test/libsolidity/syntaxTests/tryCatch/scoping.sol
Normal file
10
test/libsolidity/syntaxTests/tryCatch/scoping.sol
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user