Merge pull request #10527 from ethereum/errorOnMsgDataInReceive

[BREAKING] Disallowing usage of msg.data in receive() function.
This commit is contained in:
chriseth 2020-12-08 12:22:39 +01:00 committed by GitHub
commit 15ef45576d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View File

@ -19,6 +19,7 @@ Breaking Changes:
* Type System: Explicit conversions between two types are disallowed if it changes more than one of sign, width or kind at the same time.
* Type System: Declarations with the name ``this``, ``super`` and ``_`` are disallowed, with the exception of public functions and events.
* Type System: Disallow ``type(super)``.
* Type System: Disallow ``msg.data`` in ``receive()`` function.
* Command Line Interface: JSON fields `abi`, `devdoc`, `userdoc` and `storage-layout` are now sub-objects rather than strings.
* Scanner: Remove support for the ``\b``, ``\f``, and ``\v`` escape sequences.

View File

@ -224,6 +224,17 @@ bool StaticAnalyzer::visit(MemberAccess const& _memberAccess)
"Because of that, it might be that the deployed bytecode is different from type(...).runtimeCode."
);
}
else if (
m_currentFunction &&
m_currentFunction->isReceive() &&
type->kind() == MagicType::Kind::Message &&
_memberAccess.memberName() == "data"
)
m_errorReporter.typeError(
7139_error,
_memberAccess.location(),
R"("msg.data" cannot be used inside of "receive" function.)"
);
}
if (_memberAccess.memberName() == "callcode")

View File

@ -0,0 +1,5 @@
contract C {
receive() external payable { msg.data; }
}
// ----
// TypeError 7139: (46-54): "msg.data" cannot be used inside of "receive" function.