mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #5487 from ethereum/fixInterfaceOverrideTypeChange
Fix interface override type change
This commit is contained in:
commit
80fa898c44
@ -3,7 +3,6 @@
|
|||||||
Language Features:
|
Language Features:
|
||||||
* Allow public functions to override external functions.
|
* Allow public functions to override external functions.
|
||||||
|
|
||||||
|
|
||||||
Compiler Features:
|
Compiler Features:
|
||||||
* Build System: LLL is not built anymore by default. Must configure it with CMake as `-DLLL=ON`.
|
* Build System: LLL is not built anymore by default. Must configure it with CMake as `-DLLL=ON`.
|
||||||
* Code generator: Do not perform redundant double cleanup on unsigned integers when loading from calldata.
|
* Code generator: Do not perform redundant double cleanup on unsigned integers when loading from calldata.
|
||||||
@ -16,6 +15,7 @@ Compiler Features:
|
|||||||
Bugfixes:
|
Bugfixes:
|
||||||
* Assembly output: Do not mix in/out jump annotations with arguments.
|
* Assembly output: Do not mix in/out jump annotations with arguments.
|
||||||
* Code Generator: Annotate jump from calldata decoder to function as "jump in".
|
* Code Generator: Annotate jump from calldata decoder to function as "jump in".
|
||||||
|
* Type Checker: Properly detect different return types when overriding an external interface function with a public contract function.
|
||||||
|
|
||||||
Build System:
|
Build System:
|
||||||
* Emscripten: Upgrade to Emscripten SDK 1.37.21 and boost 1.67.
|
* Emscripten: Upgrade to Emscripten SDK 1.37.21 and boost 1.67.
|
||||||
|
@ -409,6 +409,8 @@ void TypeChecker::checkFunctionOverride(FunctionDefinition const& _function, Fun
|
|||||||
|
|
||||||
if (!functionType->hasEqualParameterTypes(*superType))
|
if (!functionType->hasEqualParameterTypes(*superType))
|
||||||
return;
|
return;
|
||||||
|
if (!functionType->hasEqualReturnTypes(*superType))
|
||||||
|
overrideError(_function, _super, "Overriding function return types differ.");
|
||||||
|
|
||||||
if (!_function.annotation().superFunction)
|
if (!_function.annotation().superFunction)
|
||||||
_function.annotation().superFunction = &_super;
|
_function.annotation().superFunction = &_super;
|
||||||
@ -423,7 +425,7 @@ void TypeChecker::checkFunctionOverride(FunctionDefinition const& _function, Fun
|
|||||||
))
|
))
|
||||||
overrideError(_function, _super, "Overriding function visibility differs.");
|
overrideError(_function, _super, "Overriding function visibility differs.");
|
||||||
}
|
}
|
||||||
else if (_function.stateMutability() != _super.stateMutability())
|
if (_function.stateMutability() != _super.stateMutability())
|
||||||
overrideError(
|
overrideError(
|
||||||
_function,
|
_function,
|
||||||
_super,
|
_super,
|
||||||
@ -433,8 +435,6 @@ void TypeChecker::checkFunctionOverride(FunctionDefinition const& _function, Fun
|
|||||||
stateMutabilityToString(_function.stateMutability()) +
|
stateMutabilityToString(_function.stateMutability()) +
|
||||||
"\"."
|
"\"."
|
||||||
);
|
);
|
||||||
else if (*functionType != *superType)
|
|
||||||
overrideError(_function, _super, "Overriding function return types differ.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TypeChecker::overrideError(FunctionDefinition const& function, FunctionDefinition const& super, string message)
|
void TypeChecker::overrideError(FunctionDefinition const& function, FunctionDefinition const& super, string message)
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
interface I {
|
||||||
|
function f() external pure returns (uint);
|
||||||
|
}
|
||||||
|
contract B is I {
|
||||||
|
// The compiler used to have a bug where changing
|
||||||
|
// the return type was fine in this situation.
|
||||||
|
function f() public pure returns (uint, uint) {}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError: (182-230): Overriding function return types differ.
|
@ -4,3 +4,4 @@ contract C {
|
|||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// DeclarationError: (17-66): Function with same name and arguments defined twice.
|
// DeclarationError: (17-66): Function with same name and arguments defined twice.
|
||||||
|
// TypeError: (17-66): Overriding function return types differ.
|
||||||
|
Loading…
Reference in New Issue
Block a user