Solidity ParserError:预期为“;” 但得到了“{”

Kev*_* A. 2 solidity

使用版本0.6.0

pragma solidity ^0.6.0;

contract Test {
    function sendValue(address payable recipient, uint256 amount) external {
        (bool success, ) = recipient.call{ value: amount }("");
    }
}
Run Code Online (Sandbox Code Playgroud)

Test.sol:5:42:ParserError:预期为“;” 但得到 '{' (bool success, ) =recipient.call{ value: amount }(""); ^

为什么会出现这个错误?

Pet*_*jda 7

您正在使用 Solidity 0.7 中引入的语法,但在 0.6 中尚未有效。

对于 0.6,请使用:

(bool success, ) = recipient.call.value(amount)("");
Run Code Online (Sandbox Code Playgroud)

来源和更多信息: