diff options
author | chriseth <chris@ethereum.org> | 2017-03-02 19:08:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-02 19:08:17 +0800 |
commit | 5c411b472b5830efa798309e1e7ed728acafdfa3 (patch) | |
tree | 302b4295d85b4dc12cc53d2e80b778b6fd0b5fb2 | |
parent | 6ac2c15c2bbcce77cf60e5a1d6bb78b924609af7 (diff) | |
parent | b832b70e1bf09087005f0e620fa5e20d57fd3310 (diff) | |
download | dexon-solidity-5c411b472b5830efa798309e1e7ed728acafdfa3.tar.gz dexon-solidity-5c411b472b5830efa798309e1e7ed728acafdfa3.tar.zst dexon-solidity-5c411b472b5830efa798309e1e7ed728acafdfa3.zip |
Merge pull request #1728 from ethereum/externalfunctiontypes
Convert reference types to pointers in member function conversion.
-rw-r--r-- | Changelog.md | 1 | ||||
-rw-r--r-- | libsolidity/ast/Types.cpp | 2 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 17 |
3 files changed, 19 insertions, 1 deletions
diff --git a/Changelog.md b/Changelog.md index c46ba3bd..3eaadf21 100644 --- a/Changelog.md +++ b/Changelog.md @@ -13,6 +13,7 @@ Bugfixes: * Type system: Fix a crash caused by continuing on fatal errors in the code. * Type system: Disallow arrays with negative length. * Type system: Fix a crash related to invalid binary operators. + * Type system: Correctly convert function argument types to pointers for member functions. * Inline assembly: Charge one stack slot for non-value types during analysis. * Assembly output: Print source location before the operation it refers to instead of after. diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 99d6f4a2..7f267cc9 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -2493,7 +2493,7 @@ FunctionTypePointer FunctionType::asMemberFunction(bool _inLibrary, bool _bound) { auto refType = dynamic_cast<ReferenceType const*>(t.get()); if (refType && refType->location() == DataLocation::CallData) - parameterTypes.push_back(refType->copyForLocation(DataLocation::Memory, false)); + parameterTypes.push_back(refType->copyForLocation(DataLocation::Memory, true)); else parameterTypes.push_back(t); } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index bb274614..866bd9aa 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -4736,6 +4736,23 @@ BOOST_AUTO_TEST_CASE(delete_external_function_type_invalid) CHECK_ERROR(text, TypeError, ""); } +BOOST_AUTO_TEST_CASE(external_function_to_function_type_calldata_parameter) +{ + // This is a test that checks that the type of the `bytes` parameter is + // correctly changed from its own type `bytes calldata` to `bytes memory` + // when converting to a function type. + char const* text = R"( + contract C { + function f(function(bytes memory x) external g) { } + function callback(bytes x) external {} + function g() { + f(this.callback); + } + } + )"; + CHECK_SUCCESS(text); +} + BOOST_AUTO_TEST_CASE(external_function_type_to_address) { char const* text = R"( |