aboutsummaryrefslogtreecommitdiffstats
path: root/AST.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-02-20 00:43:53 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-02-20 00:43:53 +0800
commit26132363d5a11d762224cc7c8acc6b8c854cf646 (patch)
tree603b725cc99d0c7f636f876ff414c3672fea8696 /AST.cpp
parenta2f5ea88b8e3a010c5543ef341bc111d3e958de0 (diff)
downloaddexon-solidity-26132363d5a11d762224cc7c8acc6b8c854cf646.tar.gz
dexon-solidity-26132363d5a11d762224cc7c8acc6b8c854cf646.tar.zst
dexon-solidity-26132363d5a11d762224cc7c8acc6b8c854cf646.zip
Bugfix for functions override
- Functions with byte array type parameters can now be safely overriden. Parameter location is now set at the right place. - Also made a test for the fix
Diffstat (limited to 'AST.cpp')
-rw-r--r--AST.cpp19
1 files changed, 4 insertions, 15 deletions
diff --git a/AST.cpp b/AST.cpp
index c6d8f5c5..761427db 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -274,15 +274,6 @@ TypePointer FunctionDefinition::getType(ContractDefinition const*) const
void FunctionDefinition::checkTypeRequirements()
{
- // change all byte arrays parameters to point to calldata
- if (getVisibility() == Visibility::External)
- for (ASTPointer<VariableDeclaration> const& var: getParameters())
- {
- auto const& type = var->getType();
- solAssert(!!type, "");
- if (auto const* byteArrayType = dynamic_cast<ByteArrayType const*>(type.get()))
- var->setType(byteArrayType->copyForLocation(ByteArrayType::Location::CallData));
- }
for (ASTPointer<VariableDeclaration> const& var: getParameters() + getReturnParameters())
if (!var->getType()->canLiveOutsideStorage())
BOOST_THROW_EXCEPTION(var->createTypeError("Type is required to live outside storage."));
@@ -299,16 +290,14 @@ string FunctionDefinition::getCanonicalSignature() const
bool VariableDeclaration::isLValue() const
{
- if (auto const* function = dynamic_cast<FunctionDefinition const*>(getScope()))
- if (function->getVisibility() == Declaration::Visibility::External && isFunctionParameter())
- return false;
- return true;
+ // External function parameters are Read-Only
+ return !isExternalFunctionParameter();
}
-bool VariableDeclaration::isFunctionParameter() const
+bool VariableDeclaration::isExternalFunctionParameter() const
{
auto const* function = dynamic_cast<FunctionDefinition const*>(getScope());
- if (!function)
+ if (!function || function->getVisibility() != Declaration::Visibility::External)
return false;
for (auto const& variable: function->getParameters())
if (variable.get() == this)