mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[TypeChecker] Remove function input and return parameter names from mobileType
This commit is contained in:
parent
ba4e05c62c
commit
e7d5a7da10
@ -32,6 +32,7 @@ Bugfixes:
|
||||
* NatSpec: Constructors and functions have consistent userdoc output.
|
||||
* Inheritance: Disallow public state variables overwriting ``pure`` functions.
|
||||
* State Mutability: Constant public state variables are considered ``pure`` functions.
|
||||
* Type Checker: Fixing deduction issues on function types when function call has named arguments.
|
||||
|
||||
|
||||
### 0.6.12 (2020-07-22)
|
||||
|
@ -1293,9 +1293,9 @@ bool TypeChecker::visit(Conditional const& _conditional)
|
||||
|
||||
if (_conditional.annotation().willBeWrittenTo)
|
||||
m_errorReporter.typeError(
|
||||
2212_error,
|
||||
_conditional.location(),
|
||||
"Conditional expression as left value is not supported yet."
|
||||
2212_error,
|
||||
_conditional.location(),
|
||||
"Conditional expression as left value is not supported yet."
|
||||
);
|
||||
|
||||
return false;
|
||||
|
@ -3425,6 +3425,28 @@ TypeResult FunctionType::interfaceType(bool /*_inLibrary*/) const
|
||||
return TypeResult::err("Internal type is not allowed for public or external functions.");
|
||||
}
|
||||
|
||||
TypePointer FunctionType::mobileType() const
|
||||
{
|
||||
if (m_valueSet || m_gasSet || m_saltSet || m_bound)
|
||||
return nullptr;
|
||||
|
||||
// return function without parameter names
|
||||
return TypeProvider::function(
|
||||
m_parameterTypes,
|
||||
m_returnParameterTypes,
|
||||
strings(m_parameterTypes.size()),
|
||||
strings(m_returnParameterNames.size()),
|
||||
m_kind,
|
||||
m_arbitraryParameters,
|
||||
m_stateMutability,
|
||||
m_declaration,
|
||||
m_gasSet,
|
||||
m_valueSet,
|
||||
m_bound,
|
||||
m_saltSet
|
||||
);
|
||||
}
|
||||
|
||||
bool FunctionType::canTakeArguments(
|
||||
FuncCallArguments const& _arguments,
|
||||
Type const* _selfType
|
||||
|
@ -1234,6 +1234,7 @@ public:
|
||||
MemberList::MemberMap nativeMembers(ASTNode const* _currentScope) const override;
|
||||
TypePointer encodingType() const override;
|
||||
TypeResult interfaceType(bool _inLibrary) const override;
|
||||
TypePointer mobileType() const override;
|
||||
|
||||
/// @returns TypePointer of a new FunctionType object. All input/return parameters are an
|
||||
/// appropriate external types (i.e. the interfaceType()s) of input/return parameters of
|
||||
|
@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function g(int x, int y) public pure returns (int) { return x - y; }
|
||||
function h(int y, int x) public pure returns (int) { return y - x; }
|
||||
|
||||
function f() public pure returns (int) {
|
||||
return (false ? g : h)(2, 1);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// f() -> 1
|
@ -0,0 +1,14 @@
|
||||
contract C {
|
||||
function g(int x, int y) public pure returns (int) { return x - y; }
|
||||
function h(int y, int x) public pure returns (int) { return y - x; }
|
||||
|
||||
function f() public pure {
|
||||
(true ? g : h)({x : 1, y : 2});
|
||||
[g, h][1]({x : 1, y : 2});
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 4974: (199-229): Named argument "x" does not match function declaration.
|
||||
// TypeError 4974: (199-229): Named argument "y" does not match function declaration.
|
||||
// TypeError 4974: (239-264): Named argument "x" does not match function declaration.
|
||||
// TypeError 4974: (239-264): Named argument "y" does not match function declaration.
|
Loading…
Reference in New Issue
Block a user