Skip to content

Commit d8030c9

Browse files
authored
Merge pull request argotorg#3880 from ethereum/addressMemberDocAndWarn
Improve documentation and warning about accessing contract members in…
2 parents 73ca3e8 + 05c5ab1 commit d8030c9

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Features:
1818
* Syntax Checker: Issue warning for empty structs (or error as experimental 0.5.0 feature).
1919
* Syntax Checker: Warn about modifiers on functions without implementation (this will turn into an error with version 0.5.0).
2020
* Syntax Tests: Add source locations to syntax test expectations.
21+
* Type Checker: Improve documentation and warnings for accessing contract members inherited from ``address``.
2122
* General: Introduce new constructor syntax using the ``constructor`` keyword as experimental 0.5.0 feature.
2223
* Inheritance: Error when using empty parentheses for base class constructors that require arguments as experimental 0.5.0 feature.
2324
* Inheritance: Error when using no parentheses in modifier-style constructor calls as experimental 0.5.0 feature.

docs/types.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ All three functions ``call``, ``delegatecall`` and ``callcode`` are very low-lev
179179
The ``.gas()`` option is available on all three methods, while the ``.value()`` option is not supported for ``delegatecall``.
180180

181181
.. note::
182-
All contracts inherit the members of address, so it is possible to query the balance of the
183-
current contract using ``this.balance``.
182+
All contracts can be converted to ``address`` type, so it is possible to query the balance of the
183+
current contract using ``address(this).balance``.
184184

185185
.. note::
186186
The use of ``callcode`` is discouraged and will be removed in the future.

libsolidity/analysis/TypeChecker.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1988,7 +1988,8 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
19881988
m_errorReporter.warning(
19891989
_memberAccess.location(),
19901990
"Using contract member \"" + memberName +"\" inherited from the address type is deprecated." +
1991-
" Convert the contract to \"address\" type to access the member."
1991+
" Convert the contract to \"address\" type to access the member,"
1992+
" for example use \"address(contract)." + memberName + "\" instead."
19921993
);
19931994
}
19941995

0 commit comments

Comments
 (0)