Merge pull request #10886 from ethereum/issue-10874

OverrideSpecifier: Check for null before dereferencing
This commit is contained in:
chriseth 2021-02-04 14:12:07 +01:00 committed by GitHub
commit d4ce896582
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View File

@ -7,6 +7,7 @@ Compiler Features:
Bugfixes:
* Type Checker: Fix internal error when override specifier is not a contract.
* SMTChecker: Fix missing type constraints on block and transaction variables in the deployment phase.

View File

@ -225,13 +225,12 @@ struct OverrideSpecifierChecker: public PostTypeChecker::Checker
if (dynamic_cast<ContractDefinition const*>(decl))
continue;
TypeType const* actualTypeType = dynamic_cast<TypeType const*>(decl->type());
auto const* typeType = dynamic_cast<TypeType const*>(decl->type());
m_errorReporter.typeError(
9301_error,
override->location(),
"Expected contract but got " +
actualTypeType->actualType()->toString(true) +
(typeType ? typeType->actualType() : decl->type())->toString(true) +
"."
);
}

View File

@ -0,0 +1,12 @@
contract A {
function f() public virtual {}
}
contract B {
function g() public {}
}
contract C is A,B {
function f() public override (g) {}
}
// ----
// TypeError 9301: (140-141): Expected contract but got function ().