Are the order of contract names inside override important?

For example, in contract Z, is

function foo() override(X, Y) {... } same as function foo() override(Y, X) {... }?

Or do they convey a different meaning?

contract X {
    function foo() public pure virtual returns (string memory) {
        return "X";

contract Y is X {
    function foo() public pure virtual override returns (string memory) {
        return "Y";

contract Z is X, Y {
    function foo() public pure override(X, Y) returns (string memory) {
        return "Z";

  • I think yes it is solidity-by-example.org/inheritance
    – Majd TL
    Commented Nov 27, 2021 at 8:52
  • but why you inheritance from X and Y? because Y inheritance already from X
    – Majd TL
    Commented Nov 27, 2021 at 9:11
  • @MajdTL For example, chain of inheritance may not be obvious. It might be A -> B -> D and A -> C -> D The example above is simplied Commented Nov 27, 2021 at 9:35

1 Answer 1


No, the order in the override specifier does not matter at all. The order in which virtual functions are considered by super is determined by inheritance order and you cannot change it by reordering contracts in override.

This is confusing to many users because people really expect that changing it means something. This is why in one of the future releases the compiler may actually start requiring the same order as on the inheritance list (see #8354).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.