mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6323 from ethereum/bug-637
Fix function calls with named arguments for overloaded functions
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
contract C {
|
||||
function f() public returns (uint) {
|
||||
return 0;
|
||||
}
|
||||
function f(uint a) public returns (uint) {
|
||||
return a;
|
||||
}
|
||||
function f(uint a, uint b) public returns (uint) {
|
||||
return a+b;
|
||||
}
|
||||
function f(uint a, uint b, uint c) public returns (uint) {
|
||||
return a+b+c;
|
||||
}
|
||||
function call(uint num) public returns (uint256) {
|
||||
if (num == 0)
|
||||
return f();
|
||||
if (num == 1)
|
||||
return f({a: 1});
|
||||
if (num == 2)
|
||||
return f({b: 1, a: 2});
|
||||
if (num == 3)
|
||||
return f({c: 1, a: 2, b: 3});
|
||||
|
||||
return 500;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// call(uint256): 0 -> 0
|
||||
// call(uint256): 1 -> 1
|
||||
// call(uint256): 2 -> 3
|
||||
// call(uint256): 3 -> 6
|
||||
// call(uint256): 4 -> 500
|
||||
@@ -0,0 +1,14 @@
|
||||
contract C {
|
||||
function f(uint x) internal { }
|
||||
function f(uint x, uint y) internal { }
|
||||
function f(uint x, uint y, uint z) internal { }
|
||||
function call() internal {
|
||||
f({x: 1});
|
||||
f({x: 1, y: 2});
|
||||
f({y: 2, x: 1});
|
||||
f({x: 1, y: 2, z: 3});
|
||||
f({z: 3, x: 1, y: 2});
|
||||
f({y: 2, z: 3, x: 1});
|
||||
}
|
||||
}
|
||||
// ----
|
||||
@@ -0,0 +1,14 @@
|
||||
contract C {
|
||||
function f(uint x) internal { }
|
||||
function f(uint x, uint y) internal { }
|
||||
function f(uint x, uint y, uint z) internal { }
|
||||
function call() internal {
|
||||
f(1, 2);
|
||||
f(1);
|
||||
|
||||
f({x: 1, y: 2});
|
||||
f({y: 2});
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (241-242): No matching declaration found after argument-dependent lookup.
|
||||
@@ -0,0 +1,12 @@
|
||||
contract C {
|
||||
function f(uint x) internal { }
|
||||
function f(uint x, uint y) internal { }
|
||||
function f(uint x, uint y, uint z) internal { }
|
||||
function call() internal {
|
||||
|
||||
f({x:1, y: 2});
|
||||
f({x:1, z: 3});
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (209-210): No matching declaration found after argument-dependent lookup.
|
||||
@@ -0,0 +1,11 @@
|
||||
contract C {
|
||||
function f(uint x) internal { }
|
||||
function f(uint x, uint y) internal { }
|
||||
function f(uint x, uint y, uint z) internal { }
|
||||
function call() internal {
|
||||
f({x:1, y: 2, z: 3});
|
||||
f({y:2, v: 10, z: 3});
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (214-215): No matching declaration found after argument-dependent lookup.
|
||||
Reference in New Issue
Block a user