Merge pull request #10506 from ethereum/superInLibs

Make super unavailable in libraries.
This commit is contained in:
chriseth 2020-12-07 14:36:42 +01:00 committed by GitHub
commit 254119d146
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 1 deletions

View File

@ -17,6 +17,7 @@ Bugfixes:
* SMTChecker: Fix internal compiler error when doing bitwise compound assignment with string literals.
* SMTChecker: Fix internal error when trying to generate counterexamples with old z3.
* SMTChecker: Fix segmentation fault that could occur on certain SMT-enabled sources when no SMT solver was available.
* Type Checker: ``super`` is not available in libraries.
* Yul Optimizer: Fix a bug in NameSimplifier where a new name created by NameSimplifier could also be created by NameDispenser.
* Yul Optimizer: Removed NameSimplifier from optimization steps available to users.

View File

@ -285,7 +285,8 @@ bool NameAndTypeResolver::resolveNamesAndTypesInternal(ASTNode& _node, bool _res
solAssert(_resolveInsideCode, "");
m_globalContext.setCurrentContract(*contract);
updateDeclaration(*m_globalContext.currentSuper());
if (!contract->isLibrary())
updateDeclaration(*m_globalContext.currentSuper());
updateDeclaration(*m_globalContext.currentThis());
for (ASTPointer<InheritanceSpecifier> const& baseContract: contract->baseContracts())

View File

@ -0,0 +1,7 @@
contract C {
}
function f() pure {
super;
}
// ----
// DeclarationError 7576: (39-44): Undeclared identifier. "super" is not (or not yet) visible at this point.

View File

@ -0,0 +1,7 @@
library L {
function f() public {
(super);
}
}
// ----
// DeclarationError 7576: (41-46): Undeclared identifier. "super" is not (or not yet) visible at this point.