mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallow defining operators with non-pure functions
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
type Int is int16;
|
||||
|
||||
using {add as +} for Int;
|
||||
|
||||
function add(Int, Int) returns (Int) {
|
||||
B b = new B();
|
||||
return b.f();
|
||||
}
|
||||
|
||||
contract B {
|
||||
Int s;
|
||||
function f() external returns (Int) {
|
||||
s = Int.wrap(3);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
contract C {
|
||||
function test() public returns (Int) {
|
||||
return Int.wrap(0) + Int.wrap(0);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 7775: (27-30): Only pure functions can be used to define operators.
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using {add as +, sub as -, mul as *} for A;
|
||||
|
||||
function add(A, A) view returns (A) {}
|
||||
function sub(A, A) returns (A) {}
|
||||
function mul(A, A) payable returns (A) {}
|
||||
|
||||
type A is address payable;
|
||||
// ----
|
||||
// TypeError 7775: (7-10): Only pure functions can be used to define operators.
|
||||
// TypeError 7775: (17-20): Only pure functions can be used to define operators.
|
||||
// TypeError 7775: (27-30): Only pure functions can be used to define operators.
|
||||
// TypeError 9559: (118-159): Free functions cannot be payable.
|
||||
Reference in New Issue
Block a user