Skip to content

Commit ca4c983

Browse files
authored
Merge pull request #12695 from ethereum/less-confusing-err
Make error message less confusing
2 parents 1aacb67 + 175580f commit ca4c983

16 files changed

+25
-26
lines changed

libsolidity/analysis/ViewPureChecker.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,9 @@ void ViewPureChecker::reportMutability(
256256
m_errorReporter.typeError(
257257
8961_error,
258258
_location,
259-
"Function declared as " +
259+
"Function cannot be declared as " +
260260
stateMutabilityToString(m_currentFunction->stateMutability()) +
261-
", but this expression (potentially) modifies the state and thus "
262-
"requires non-payable (the default) or payable."
261+
" because this expression (potentially) modifies the state."
263262
);
264263
m_errors = true;
265264
}

test/libsolidity/syntaxTests/freeFunctions/free_mutability.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ function f() {
55
function g(uint[] storage x) pure { x[0] = 1; }
66
// ----
77
// Warning 2018: (0-39): Function state mutability can be restricted to pure
8-
// TypeError 8961: (76-80): Function declared as pure, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
8+
// TypeError 8961: (76-80): Function cannot be declared as pure because this expression (potentially) modifies the state.

test/libsolidity/syntaxTests/multiSource/one_source.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ contract A {
44
function f() public pure { x = 42; }
55
}
66
// ----
7-
// TypeError 8961: (SourceName:53-54): Function declared as pure, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
7+
// TypeError 8961: (SourceName:53-54): Function cannot be declared as pure because this expression (potentially) modifies the state.

test/libsolidity/syntaxTests/viewPureChecker/access_to_base_member_function.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ contract B is A {
88
}
99
}
1010
// ----
11-
// TypeError 8961: (100-105): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
11+
// TypeError 8961: (100-105): Function cannot be declared as view because this expression (potentially) modifies the state.

test/libsolidity/syntaxTests/viewPureChecker/access_to_base_member_struct.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ contract B is A {
1515
}
1616
}
1717
// ----
18-
// TypeError 8961: (107-110): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
19-
// TypeError 8961: (166-171): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
18+
// TypeError 8961: (107-110): Function cannot be declared as view because this expression (potentially) modifies the state.
19+
// TypeError 8961: (166-171): Function cannot be declared as view because this expression (potentially) modifies the state.
2020
// TypeError 2527: (244-247): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
2121
// TypeError 2527: (244-249): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".

test/libsolidity/syntaxTests/viewPureChecker/access_to_base_members.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ contract B is A {
1212
}
1313
// ----
1414
// TypeError 2527: (107-110): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
15-
// TypeError 8961: (157-160): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
15+
// TypeError 8961: (157-160): Function cannot be declared as view because this expression (potentially) modifies the state.

test/libsolidity/syntaxTests/viewPureChecker/array/access_to_array_push_view.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ contract A {
55
}
66
}
77
// ----
8-
// TypeError 8961: (88-96): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
8+
// TypeError 8961: (88-96): Function cannot be declared as view because this expression (potentially) modifies the state.

test/libsolidity/syntaxTests/viewPureChecker/builtin_functions_view_fail.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ contract C {
2020
}
2121
}
2222
// ----
23-
// TypeError 8961: (52-77): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
24-
// TypeError 8961: (132-153): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
25-
// TypeError 8961: (201-228): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
26-
// TypeError 8961: (293-323): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
27-
// TypeError 8961: (414-436): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
23+
// TypeError 8961: (52-77): Function cannot be declared as view because this expression (potentially) modifies the state.
24+
// TypeError 8961: (132-153): Function cannot be declared as view because this expression (potentially) modifies the state.
25+
// TypeError 8961: (201-228): Function cannot be declared as view because this expression (potentially) modifies the state.
26+
// TypeError 8961: (293-323): Function cannot be declared as view because this expression (potentially) modifies the state.
27+
// TypeError 8961: (414-436): Function cannot be declared as view because this expression (potentially) modifies the state.

test/libsolidity/syntaxTests/viewPureChecker/call_internal_functions_fail.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ contract C {
77
}
88
// ----
99
// TypeError 2527: (56-59): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
10-
// TypeError 8961: (130-133): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
10+
// TypeError 8961: (130-133): Function cannot be declared as view because this expression (potentially) modifies the state.

test/libsolidity/syntaxTests/viewPureChecker/creation_view_fail.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ contract C {
33
function f() public view { new D(); }
44
}
55
// ----
6-
// TypeError 8961: (58-65): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
6+
// TypeError 8961: (58-65): Function cannot be declared as view because this expression (potentially) modifies the state.

0 commit comments

Comments
 (0)