Skip to content

Commit f4173b2

Browse files
Emit deprecation warnings for abi coder v1, contract comparisons, memory-safe-assembly, send and transfer functions, and virtual modifiers.
1 parent 5ef96c9 commit f4173b2

File tree

178 files changed

+851
-28
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+851
-28
lines changed

Changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ Language Features:
66
Compiler Features:
77
* ethdebug: Experimental support for instructions and source locations under EOF.
88
* EVM: Set default EVM Version to `osaka`.
9+
* DocString Parser: Warn about deprecation of inline assembly special comment `memory-safe-assembly`.
10+
* Syntax Checker: Warn about deprecation of ABI coder v1.
11+
* Syntax Checker: Warn about deprecation of virtual modifiers.
12+
* Type Checker: Warn about deprecation of `send` and `transfer` functions on instances of `address`.
13+
* Type Checker: Warn about deprecation of comparisons between variables of contract types.
914

1015
Bugfixes:
1116
* Assembler: Fix not using a fixed-width type for IDs being assigned to subassemblies nested more than one level away, resulting in inconsistent `--asm-json` output between target architectures.

libsolidity/analysis/DocStringTagParser.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,18 @@ bool DocStringTagParser::visit(InlineAssembly const& _assembly)
206206
m_errorReporter.warning(
207207
8544_error,
208208
_assembly.location(),
209-
"Inline assembly marked as memory safe using both a NatSpec tag and an assembly flag. "
210-
"If you are not concerned with backwards compatibility, only use the assembly flag, "
209+
"Inline assembly marked as memory safe using both a NatSpec tag and an assembly block annotation. "
210+
"If you are not concerned with backwards compatibility, only use the assembly block annotation, "
211211
"otherwise only use the NatSpec tag."
212212
);
213213
_assembly.annotation().markedMemorySafe = true;
214+
m_errorReporter.warning(
215+
2424_error,
216+
_assembly.location(),
217+
"Natspec memory-safe-assembly special comment for inline assembly is deprecated and "
218+
"scheduled for removal. "
219+
"Use the memory-safe block annotation instead."
220+
);
214221
}
215222
else
216223
m_errorReporter.warning(

libsolidity/analysis/SyntaxChecker.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma)
149149
);
150150
else
151151
m_sourceUnit->annotation().useABICoderV2 = (_pragma.literals()[1] == "v2");
152+
153+
if (
154+
_pragma.literals().size() > 1 &&
155+
_pragma.literals()[1] == "v1"
156+
)
157+
m_errorReporter.warning(
158+
9511_error,
159+
_pragma.location(),
160+
"ABI coder v1 is deprecated and scheduled for removal. Use ABI coder v2 instead."
161+
);
152162
}
153163
else if (_pragma.literals()[0] == "solidity")
154164
{
@@ -184,6 +194,14 @@ void SyntaxChecker::endVisit(ModifierDefinition const& _modifier)
184194
{
185195
if (_modifier.isImplemented() && !m_placeholderFound)
186196
m_errorReporter.syntaxError(2883_error, _modifier.body().location(), "Modifier body does not contain '_'.");
197+
198+
if (_modifier.markedVirtual())
199+
m_errorReporter.warning(
200+
8429_error,
201+
_modifier.location(),
202+
"Virtual modifiers are deprecated and scheduled for removal."
203+
);
204+
187205
m_placeholderFound = false;
188206
}
189207

libsolidity/analysis/TypeChecker.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,6 +1829,16 @@ void TypeChecker::endVisit(BinaryOperation const& _operation)
18291829
)
18301830
);
18311831
}
1832+
if (
1833+
TokenTraits::isCompareOp(_operation.getOperator()) &&
1834+
commonType->category() == Type::Category::Contract
1835+
)
1836+
m_errorReporter.warning(
1837+
9170_error,
1838+
_operation.location(),
1839+
"Comparison of variables of contract type is deprecated and scheduled for removal. "
1840+
"Use an explicit cast to address type and compare the addresses instead."
1841+
);
18321842
}
18331843

18341844
Type const* TypeChecker::typeCheckTypeConversionAndRetrieveReturnType(
@@ -3212,6 +3222,19 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
32123222
if (contractType && contractType->isSuper())
32133223
requiredLookup = VirtualLookup::Super;
32143224
}
3225+
3226+
if (
3227+
funType->kind() == FunctionType::Kind::Send ||
3228+
funType->kind() == FunctionType::Kind::Transfer
3229+
)
3230+
m_errorReporter.warning(
3231+
9207_error,
3232+
_memberAccess.location(),
3233+
fmt::format(
3234+
"'{}' is deprecated and scheduled for removal. Use 'call{{value: <amount>}}(\"\")' instead.",
3235+
funType->kind() == FunctionType::Kind::Send ? "send" : "transfer"
3236+
)
3237+
);
32153238
}
32163239

32173240
annotation.requiredLookup = requiredLookup;

test/cmdlineTests/model_checker_targets_all_all_engines/err

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Warning: 'transfer' is deprecated and scheduled for removal. Use 'call{value: <amount>}("")' instead.
2+
--> input.sol:10:3:
3+
|
4+
10 | a.transfer(x);
5+
| ^^^^^^^^^^
6+
17
Warning: CHC: Underflow (resulting value less than 0) happens here.
28
Counterexample:
39
arr = []

test/cmdlineTests/model_checker_targets_all_bmc/err

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Warning: 'transfer' is deprecated and scheduled for removal. Use 'call{value: <amount>}("")' instead.
2+
--> input.sol:10:3:
3+
|
4+
10 | a.transfer(x);
5+
| ^^^^^^^^^^
6+
17
Warning: BMC: Condition is always true.
28
--> input.sol:6:11:
39
|

test/cmdlineTests/model_checker_targets_all_chc/err

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Warning: 'transfer' is deprecated and scheduled for removal. Use 'call{value: <amount>}("")' instead.
2+
--> input.sol:10:3:
3+
|
4+
10 | a.transfer(x);
5+
| ^^^^^^^^^^
6+
17
Warning: CHC: Underflow (resulting value less than 0) happens here.
28
Counterexample:
39
arr = []

test/cmdlineTests/model_checker_targets_assert_bmc/err

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Warning: 'transfer' is deprecated and scheduled for removal. Use 'call{value: <amount>}("")' instead.
2+
--> input.sol:10:3:
3+
|
4+
10 | a.transfer(x);
5+
| ^^^^^^^^^^
6+
17
Warning: BMC: Assertion violation happens here.
28
--> input.sol:11:3:
39
|

test/cmdlineTests/model_checker_targets_assert_chc/err

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Warning: 'transfer' is deprecated and scheduled for removal. Use 'call{value: <amount>}("")' instead.
2+
--> input.sol:10:3:
3+
|
4+
10 | a.transfer(x);
5+
| ^^^^^^^^^^
6+
17
Warning: CHC: Assertion violation happens here.
28
Counterexample:
39
arr = []

test/cmdlineTests/model_checker_targets_balance_bmc/err

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Warning: 'transfer' is deprecated and scheduled for removal. Use 'call{value: <amount>}("")' instead.
2+
--> input.sol:10:3:
3+
|
4+
10 | a.transfer(x);
5+
| ^^^^^^^^^^
6+
17
Warning: BMC: Insufficient funds happens here.
28
--> input.sol:10:3:
39
|

0 commit comments

Comments
 (0)