Solidity: Turn deprecation warning into error for .gas and .value

Created on 15 Jan 2020  路  4Comments  路  Source: ethereum/solidity

Most helpful comment

To elaborate a bit:
We recently introduced new syntax for specifying gas and value for external function calls. The old syntax was:

contract C {
    function g() external payable {}
    function f() public payable {
        this.g.value(42).gas(23)();
    }
}

The new syntax is:

contract C {
    function g() external payable {}
    function f() public payable {
        this.g{value: 42, gas: 23}();
    }
}

Similarly, the syntax for contract creation new C.value(42)() was replaced by new C{ value: 42}().
While we need to support the old syntax until the next breaking release, we should add a deprecation warning for it now.
The first part for function calls will entail modifying TypeChecker::visit(MemberAccess const&) to emit a warning along the lines of ".value(...)() is deprecated. Use {value: ...}() instead." (we can discuss the precise wording) and to update the tests accordingly. Contract creation we can either handle in the same or in a separate PR.

All 4 comments

The alternative is fully implemented now.

To elaborate a bit:
We recently introduced new syntax for specifying gas and value for external function calls. The old syntax was:

contract C {
    function g() external payable {}
    function f() public payable {
        this.g.value(42).gas(23)();
    }
}

The new syntax is:

contract C {
    function g() external payable {}
    function f() public payable {
        this.g{value: 42, gas: 23}();
    }
}

Similarly, the syntax for contract creation new C.value(42)() was replaced by new C{ value: 42}().
While we need to support the old syntax until the next breaking release, we should add a deprecation warning for it now.
The first part for function calls will entail modifying TypeChecker::visit(MemberAccess const&) to emit a warning along the lines of ".value(...)() is deprecated. Use {value: ...}() instead." (we can discuss the precise wording) and to update the tests accordingly. Contract creation we can either handle in the same or in a separate PR.

@mijovic will be working on this.

With https://github.com/ethereum/solidity/pull/8413 we started issuing warnings about this. I'll keep the issue open for turning this into errors for 0.7, though.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chriseth picture chriseth  路  3Comments

axic picture axic  路  3Comments

VoR0220 picture VoR0220  路  4Comments

madvas picture madvas  路  3Comments

chriseth picture chriseth  路  4Comments