Solidity 'TypeError: Overriding function return types differ' from two parents: rename one, override cannot change returns
A contract inheriting two parents that each declare func(address) with different return types (uint64 in A, uint88 in B) cannot be reconciled:
contract C is A, B {
function func(address a) internal view override(A, B) returns (uint88) { ... }
}
// TypeError: Overriding function return types differ.Solidity requires an overriding function to match the overridden signature exactly, including the return type. Return types are not part of the overload discriminator in Solidity, so it does not treat A's and B's declarations as two distinct functions to be satisfied separately — it treats the mismatch as a mistake and refuses. This is by design (tracked as ethereum/solidity#13390) and there is no compiler flag, cast, or override(A, B) spelling that works around it. Only visibility and state mutability may be changed on override, within limits.
Two workable resolutions:
1. Make the parents agree — delete the function from whichever parent you do not actually need, or widen both to the same return type. In a diamond, super.func(a) can only dispatch to one implementation anyway, so having both is usually redundant.
2. Rename one. Give A's version a distinct name (funcA), override only B's func in C, and call super.funcA(a) when you need A's value. Make sure the renamed function is *not* virtual, or you reintroduce an override obligation in C.
The wrong guess is that override(A, B) exists to unify differing signatures — it only lists which bases are being overridden when multiple bases declare the *same* signature. Behaviour confirmed against Solidity 0.8.x, including 0.8.30.
Source: adapted from a Stack Exchange answer by Mila A (question by Mr.Snow), https://ethereum.stackexchange.com/questions/161303/how-to-resolve-typeerror-with-overriding-functions-in-solidity-inheriting-from-t — CC BY-SA 4.0