Skip to content

Commit d4ce896

Browse files
authored
Merge pull request #10886 from ethereum/issue-10874
OverrideSpecifier: Check for null before dereferencing
2 parents 8a414d3 + 3a8a74c commit d4ce896

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Compiler Features:
77

88

99
Bugfixes:
10+
* Type Checker: Fix internal error when override specifier is not a contract.
1011
* SMTChecker: Fix missing type constraints on block and transaction variables in the deployment phase.
1112

1213

libsolidity/analysis/PostTypeChecker.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,12 @@ struct OverrideSpecifierChecker: public PostTypeChecker::Checker
225225
if (dynamic_cast<ContractDefinition const*>(decl))
226226
continue;
227227

228-
TypeType const* actualTypeType = dynamic_cast<TypeType const*>(decl->type());
229-
228+
auto const* typeType = dynamic_cast<TypeType const*>(decl->type());
230229
m_errorReporter.typeError(
231230
9301_error,
232231
override->location(),
233232
"Expected contract but got " +
234-
actualTypeType->actualType()->toString(true) +
233+
(typeType ? typeType->actualType() : decl->type())->toString(true) +
235234
"."
236235
);
237236
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
contract A {
2+
function f() public virtual {}
3+
}
4+
contract B {
5+
function g() public {}
6+
}
7+
contract C is A,B {
8+
function f() public override (g) {}
9+
}
10+
11+
// ----
12+
// TypeError 9301: (140-141): Expected contract but got function ().

0 commit comments

Comments
 (0)