Skip to content

Commit 8234fa1

Browse files
Fixes ICE when overriding an implemented modifier with an unimplemented one.
1 parent 8de575f commit 8234fa1

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Bugfixes:
3131
* Type Checker: Fix internal compiler error when attempting to use an invalid external function type on pre-byzantium EVMs.
3232
* Type Checker: Make errors about (nested) mapping type in event or error parameter into fatal type errors.
3333
* Type Checker: Fix internal compiler error when overriding receive ether function with one having different parameters during inheritance.
34+
* Type Checker: Fix internal compiler error when overriding an implemented modifier with an unimplemented one.
3435

3536

3637
AST Changes:

libsolidity/analysis/OverrideChecker.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,19 @@ void OverrideChecker::checkOverride(OverrideProxy const& _overriding, OverridePr
573573
);
574574
}
575575

576+
if (_overriding.unimplemented() && !_super.unimplemented())
577+
{
578+
solAssert(!_overriding.isVariable() || !_overriding.unimplemented(), "");
579+
overrideError(
580+
_overriding,
581+
_super,
582+
4593_error,
583+
"Overriding an implemented " + _super.astNodeName() +
584+
" with an unimplemented " + _overriding.astNodeName() +
585+
" is not allowed."
586+
);
587+
}
588+
576589
if (_super.isFunction())
577590
{
578591
FunctionType const* functionType = _overriding.functionType();
@@ -613,14 +626,6 @@ void OverrideChecker::checkOverride(OverrideProxy const& _overriding, OverridePr
613626
stateMutabilityToString(_overriding.stateMutability()) +
614627
"\"."
615628
);
616-
617-
if (_overriding.unimplemented() && !_super.unimplemented())
618-
overrideError(
619-
_overriding,
620-
_super,
621-
4593_error,
622-
"Overriding an implemented function with an unimplemented function is not allowed."
623-
);
624629
}
625630
}
626631

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
contract A {
2+
modifier m() virtual { _; }
3+
}
4+
abstract contract B is A {
5+
modifier m() virtual override;
6+
}
7+
contract C is B {
8+
function f() m public {}
9+
}
10+
// ----
11+
// TypeError 4593: (78-108): Overriding an implemented modifier with an unimplemented modifier is not allowed.

0 commit comments

Comments
 (0)