Skip to content

Commit

Permalink
Issue warning when using deprecated SELFDESTRUCT
Browse files Browse the repository at this point in the history
  • Loading branch information
nikola-matic committed Jan 19, 2023
1 parent c195782 commit 663d66d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Compiler Features:
* SMTChecker: Make ``z3`` the default solver for the BMC and CHC engines instead of all solvers.
* Parser: More detailed error messages about invalid version pragmas.
* Removed support for the ``solidity-upgrade`` tool.
* TypeChecker: Warn when using deprecated bulitin ``selfdestruct``.


Bugfixes:
Expand Down
6 changes: 6 additions & 0 deletions libsolidity/analysis/TypeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3642,6 +3642,12 @@ bool TypeChecker::visit(Identifier const& _identifier)
_identifier.location(),
"\"suicide\" has been deprecated in favour of \"selfdestruct\"."
);
else if (_identifier.name() == "selfdestruct" && fType->kind() == FunctionType::Kind::Selfdestruct)
m_errorReporter.warning(
5159_error,
_identifier.location(),
"\"selfdestruct\" has been deprecated."
);
}

if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ contract C {
function f() pure public { selfdestruct; }
}
// ----
// Warning 5159: (44-56): "selfdestruct" has been deprecated.
// Warning 6133: (44-56): Statement has no effect.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ contract C {
}
}
// ----
// Warning 5159: (56-68): "selfdestruct" has been deprecated.
// TypeError 9553: (69-70): Invalid type for argument in function call. Invalid implicit conversion from address to address payable requested.
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ contract C {
}
}
// ----
// Warning 5159: (64-76): "selfdestruct" has been deprecated.
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ contract C {
receive() payable external {}
}
// ----
// Warning 5159: (122-134): "selfdestruct" has been deprecated.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ contract C {
}
}
// ----
// Warning 5159: (201-213): "selfdestruct" has been deprecated.
// TypeError 8961: (52-77): Function cannot be declared as view because this expression (potentially) modifies the state.
// TypeError 8961: (132-153): Function cannot be declared as view because this expression (potentially) modifies the state.
// TypeError 8961: (201-228): Function cannot be declared as view because this expression (potentially) modifies the state.
Expand Down

0 comments on commit 663d66d

Please sign in to comment.