Merge pull request #10456 from ethereum/convertToSuper

Disallow conversion to super.
This commit is contained in:
chriseth 2020-12-01 15:35:59 +01:00 committed by GitHub
commit 34ee7a4dc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 0 deletions

View File

@ -2351,7 +2351,16 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
funcCallAnno.kind = FunctionCallKind::StructConstructorCall;
}
else
{
if (auto const* contractType = dynamic_cast<ContractType const*>(actualType))
if (contractType->isSuper())
m_errorReporter.fatalTypeError(
1744_error,
_functionCall.location(),
"Cannot convert to the super type."
);
funcCallAnno.kind = FunctionCallKind::TypeConversion;
}
funcCallAnno.isPure = argumentsArePure;

View File

@ -0,0 +1,7 @@
contract C {
function f() public pure {
super().x;
}
}
// ----
// TypeError 1744: (52-59): Cannot convert to the super type.

View File

@ -0,0 +1,7 @@
contract C {
function f() public pure {
super(this).f();
}
}
// ----
// TypeError 1744: (52-63): Cannot convert to the super type.