From 5942912bf1e0408573eadba8f4641c822a91ca9f Mon Sep 17 00:00:00 2001 From: wechman Date: Thu, 1 Sep 2022 10:57:39 +0200 Subject: [PATCH] Update ViewPureChecker tests for user type operator with view modifier --- .../user_operator_with_view_modifier.sol | 11 ------- .../user_operator_with_view_modifier_fail.sol | 30 +++++++++++++++++++ 2 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 test/libsolidity/syntaxTests/viewPureChecker/user_operator_with_view_modifier_fail.sol diff --git a/test/libsolidity/syntaxTests/viewPureChecker/user_operator_with_view_modifier.sol b/test/libsolidity/syntaxTests/viewPureChecker/user_operator_with_view_modifier.sol index 176889503..37eb49214 100644 --- a/test/libsolidity/syntaxTests/viewPureChecker/user_operator_with_view_modifier.sol +++ b/test/libsolidity/syntaxTests/viewPureChecker/user_operator_with_view_modifier.sol @@ -16,15 +16,4 @@ 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". diff --git a/test/libsolidity/syntaxTests/viewPureChecker/user_operator_with_view_modifier_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/user_operator_with_view_modifier_fail.sol new file mode 100644 index 000000000..176889503 --- /dev/null +++ b/test/libsolidity/syntaxTests/viewPureChecker/user_operator_with_view_modifier_fail.sol @@ -0,0 +1,30 @@ +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".