Skip to content

Commit 26598a2

Browse files
authored
Merge pull request #11569 from ethereum/fixcalltounimplementedmodifier
Prevent calls to unimplemented modifiers.
2 parents 829bf0c + c5923f7 commit 26598a2

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

Changelog.md

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

99
Bugfixes:
1010
* Code Generator: Fix internal compiler error when calling functions bound to calldata structs and arrays.
11+
* Type Checker: Fix internal error and prevent static calls to unimplemented modifiers.
1112

1213

1314
### 0.8.6 (2021-06-22)

libsolidity/analysis/TypeChecker.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,15 @@ void TypeChecker::visitManually(
639639
"Can only use modifiers defined in the current contract or in base contracts."
640640
);
641641
}
642+
if (
643+
*_modifier.name().annotation().requiredLookup == VirtualLookup::Static &&
644+
!modifierDecl->isImplemented()
645+
)
646+
m_errorReporter.typeError(
647+
1835_error,
648+
_modifier.location(),
649+
"Cannot call unimplemented modifier. The modifier has no implementation in the referenced contract. Refer to it by its unqualified name if you want to call the implementation from the most derived contract."
650+
);
642651
}
643652
else
644653
// check parameters for Base constructors
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
contract A {
2+
modifier m() virtual { _; }
3+
}
4+
abstract contract B {
5+
modifier m() virtual;
6+
}
7+
contract C is A, B {
8+
modifier m() override(A, B) { _; }
9+
function f() B.m public {}
10+
}
11+
// ----
12+
// TypeError 1835: (174-177): Cannot call unimplemented modifier. The modifier has no implementation in the referenced contract. Refer to it by its unqualified name if you want to call the implementation from the most derived contract.

0 commit comments

Comments
 (0)