mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add tests for ViewPureChecker with custom operators
This commit is contained in:
parent
545013898e
commit
6c4325ca03
@ -0,0 +1,26 @@
|
||||
type Int is uint8;
|
||||
|
||||
using {
|
||||
add as +,
|
||||
sub as -,
|
||||
mul as *
|
||||
} for Int;
|
||||
|
||||
function f_view() view {}
|
||||
|
||||
function add(Int, Int) pure returns (Int) {
|
||||
return Int.wrap(0);
|
||||
}
|
||||
|
||||
function sub(Int, Int) returns (Int) {
|
||||
return Int.wrap(0);
|
||||
}
|
||||
|
||||
function mul(Int, Int) pure returns (Int) {
|
||||
f_view();
|
||||
return Int.wrap(0);
|
||||
}
|
||||
|
||||
// ----
|
||||
// Warning 2018: (179-243): Function state mutability can be restricted to pure
|
||||
// TypeError 2527: (293-301): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
@ -0,0 +1,30 @@
|
||||
type Int is uint8;
|
||||
|
||||
using {
|
||||
add as +,
|
||||
sub as -,
|
||||
mul as *
|
||||
} for Int;
|
||||
|
||||
|
||||
function f_view() view {}
|
||||
function f() {}
|
||||
|
||||
function add(Int, Int) view returns (Int) {
|
||||
f_view();
|
||||
return Int.wrap(0);
|
||||
}
|
||||
|
||||
function sub(Int, Int) returns (Int) {
|
||||
f_view();
|
||||
return Int.wrap(0);
|
||||
}
|
||||
|
||||
function mul(Int, Int) view returns (Int) {
|
||||
f();
|
||||
return Int.wrap(0);
|
||||
}
|
||||
|
||||
// ----
|
||||
// Warning 2018: (210-288): Function state mutability can be restricted to view
|
||||
// TypeError 8961: (338-341): Function cannot be declared as view because this expression (potentially) modifies the state.
|
Loading…
Reference in New Issue
Block a user