mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Contract level checker: Disallow free function redefinition and alias
shadowing another free function Co-authored-by: chriseth <chris@ethereum.org>
This commit is contained in:
co-authored by
chriseth
parent
1cc0d642e8
commit
e2a2276272
@@ -0,0 +1,4 @@
|
||||
function f(uint24) {}
|
||||
function f(uint16) {}
|
||||
function f(int24) {}
|
||||
function f(bool) {}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function g() pure returns (uint) { return 1; }
|
||||
function g() pure returns (string memory) { return "1"; }
|
||||
contract C {
|
||||
function foo() public pure returns (uint) {
|
||||
string memory s = g();
|
||||
return 100/g();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError 1686: (0-46): Function with same name and parameter types defined twice.
|
||||
// TypeError 9574: (168-189): Type uint256 is not implicitly convertible to expected type string memory.
|
||||
@@ -0,0 +1,4 @@
|
||||
function f() pure returns (uint) { return 1337; }
|
||||
function f() pure returns (uint) { return 42; }
|
||||
// ----
|
||||
// DeclarationError 1686: (0-49): Function with same name and parameter types defined twice.
|
||||
@@ -0,0 +1,5 @@
|
||||
function f() pure returns (uint) { return 1337; }
|
||||
function f() pure returns (uint) { return 42; }
|
||||
function f() pure returns (uint) { return 1; }
|
||||
// ----
|
||||
// DeclarationError 1686: (0-49): Function with same name and parameter types defined twice.
|
||||
@@ -0,0 +1,8 @@
|
||||
function f() pure returns (uint) { return 1337; }
|
||||
contract C {
|
||||
function f() public pure returns (uint) {
|
||||
return f();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 2519: (65-126): This declaration shadows an existing declaration.
|
||||
@@ -0,0 +1,9 @@
|
||||
function f() pure returns (uint) { return 1337; }
|
||||
function f() view returns (uint) { return 42; }
|
||||
contract C {
|
||||
function g() public pure virtual returns (uint) {
|
||||
return f();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError 1686: (0-49): Function with same name and parameter types defined twice.
|
||||
Reference in New Issue
Block a user