Merge pull request #9689 from ethereum/using-for-interface

Disallow ``using for`` directive for interfaces.
This commit is contained in:
Alex Beregszaszi 2020-08-27 19:09:19 +01:00 committed by GitHub
commit e872b1b51e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 0 deletions

View File

@ -24,6 +24,7 @@ Bugfixes:
* Type Checker: Disallow signed literals as exponent in exponentiation operator.
* Allow `type(Contract).name` for abstract contracts and interfaces.
* Type Checker: Disallow structs containing nested mapping in memory as parameters for library functions.
* Type Checker: Disallow ``using for`` directive inside interfaces.
### 0.7.0 (2020-07-28)

View File

@ -3148,6 +3148,16 @@ void TypeChecker::endVisit(Literal const& _literal)
_literal.annotation().isPure = true;
}
void TypeChecker::endVisit(UsingForDirective const& _usingFor)
{
if (m_currentContract->isInterface())
m_errorReporter.typeError(
9088_error,
_usingFor.location(),
"The \"using for\" directive is not allowed inside interfaces."
);
}
bool TypeChecker::contractDependenciesAreCyclic(
ContractDefinition const& _contract,
std::set<ContractDefinition const*> const& _seenContracts

View File

@ -143,6 +143,7 @@ private:
bool visit(Identifier const& _identifier) override;
void endVisit(ElementaryTypeNameExpression const& _expr) override;
void endVisit(Literal const& _literal) override;
void endVisit(UsingForDirective const& _usingForDirective) override;
bool contractDependenciesAreCyclic(
ContractDefinition const& _contract,

View File

@ -0,0 +1,10 @@
library L {
function f() public {}
}
interface I {
using L for int;
function g() external;
}
// ----
// TypeError 9088: (60-76): The "using for" directive is not allowed inside interfaces.