User-defined operators: Tests

This commit is contained in:
wechman
2023-01-25 00:29:10 +01:00
committed by Kamil Śliwak
parent fd6359000e
commit 1edb74dbc9
85 changed files with 2138 additions and 1 deletions
@@ -0,0 +1,19 @@
type Int is uint8;
using {
add as +
} for Int;
function add(Int, Int) pure returns (Int) {
return Int.wrap(0);
}
function f() pure {
Int.wrap(0) + Int.wrap(1);
}
function g() {
Int.wrap(0) + Int.wrap(1);
}
// ----
// Warning 2018: (178-225): Function state mutability can be restricted to pure
@@ -0,0 +1,17 @@
type Int is uint8;
using {
add as +
} for Int;
function f_view() view {}
function add(Int, Int) view returns (Int) {
f_view();
return Int.wrap(0);
}
function f() view {
Int.wrap(0) + Int.wrap(0);
}
@@ -0,0 +1,28 @@
type Int is uint8;
using {
add as +
} for Int;
function f_view() view {}
function add(Int, Int) view returns (Int) {
f_view();
return Int.wrap(0);
}
function f() view {
Int.wrap(0) + Int.wrap(0);
}
function g() {
Int.wrap(0) + Int.wrap(0);
}
function h() pure {
Int.wrap(0) + Int.wrap(0);
}
// ----
// Warning 2018: (220-267): Function state mutability can be restricted to view
// TypeError 2527: (293-318): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".