使用:
solc@0.5.16
truffle@5.1.7在我聪明的合同里
pragma solidity ^0.5.12;当我有一个函数名refund()时,我收到了以下警告消息(只是一个逗号)。当我重命名函数时,警告就会消失。
Compiling your contracts...
===========================
> Compiling .\contracts\MyCoin.sol
> Compilation warnings encountered:
,编辑。我设法用最少的代码行进行复制。
pragma solidity ^0.5.12;
contract MyTest {
function refund() internal { }
function test(uint refund) public {
uint i = refund;
}
}发布于 2020-04-29 15:57:33
不,退款不是一个固定的词。
pragma solidity ^0.5.12;
contract MyTest {
function refund() internal { }
function test(uint refund) public {
uint i = refund;
}
}solc显示的警告
Warning: This declaration shadows an existing declaration.
function test(uint refund) public {
^---------^
browser/3_Ballot.sol:6:5: The shadowed declaration is here:
function refund() internal { }
^-----------------------------^是由具有与函数同名的变量或参数引起的。
如果将这两个名称都重命名为foobar,则会引起相同的警告。
发布于 2020-04-29 17:13:11
好吧,有一个函数参数和合同上的实际函数相同,这不是个好主意。当我将这段代码重新混合时,它会生成以下警告:
browser/sdfsdf.sol:4:19: Warning: This declaration shadows an existing declaration.
function test(uint refund) public {
^---------^
browser/sdfsdf.sol:3:5: The shadowed declaration is here:
function refund() internal { }
^-----------------------------^
}这在我看来是合法的。我建议换一个或另一个
https://ethereum.stackexchange.com/questions/82888
复制相似问题