mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #14365 from ethereum/declarationFunctionTypeConversions
Disallow conversions between declaration function types.
This commit is contained in:
commit
4c4410e0c5
@ -29,6 +29,7 @@ Bugfixes:
|
||||
* SMTChecker: Fix false negative when a verification target can be violated only by trusted external call from another public function.
|
||||
* SMTChecker: Fix internal error caused by using external identifier to encode member access to functions that take an internal function as a parameter.
|
||||
* Standard JSON Interface: Fix an incomplete AST being returned when analysis is interrupted by certain kinds of fatal errors.
|
||||
* Type Checker: Function declaration types referring to different declarations are no longer convertible to each other.
|
||||
* Yul Optimizer: Ensure that the assignment of memory slots for variables moved to memory does not depend on AST IDs that may depend on whether additional files are included during compilation.
|
||||
* Yul Optimizer: Fix ``FullInliner`` step not ignoring code that is not in expression-split form.
|
||||
* Yul Optimizer: Fix optimized IR being unnecessarily passed through the Yul optimizer again before bytecode generation.
|
||||
|
@ -3127,6 +3127,12 @@ BoolResult FunctionType::isImplicitlyConvertibleTo(Type const& _convertTo) const
|
||||
if (convertTo.kind() != kind())
|
||||
return BoolResult::err("Special functions cannot be converted to function types.");
|
||||
|
||||
if (
|
||||
kind() == FunctionType::Kind::Declaration &&
|
||||
m_declaration != convertTo.m_declaration
|
||||
)
|
||||
return BoolResult::err("Function declaration types referring to different functions cannot be converted to each other.");
|
||||
|
||||
if (!equalExcludingStateMutability(convertTo))
|
||||
return false;
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
contract D {
|
||||
function f() external {}
|
||||
function g() external {}
|
||||
}
|
||||
contract C {
|
||||
function f(bool c) public pure {
|
||||
(c ? D.f : D.g);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 1080: (117-130): True expression's type function D.f() does not match false expression's type function D.g().
|
@ -0,0 +1,11 @@
|
||||
contract C {
|
||||
function f() internal {}
|
||||
function g() internal {}
|
||||
}
|
||||
|
||||
contract D is C {
|
||||
function h(bool b) public pure {
|
||||
(b ? C.f : C.g);
|
||||
}
|
||||
}
|
||||
// ----
|
Loading…
Reference in New Issue
Block a user