mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Constructors cannot have calldata parameters.
This commit is contained in:
parent
375cb09341
commit
f372ba6fea
@ -19,6 +19,7 @@ Bugfixes:
|
||||
* NatSpec: Do not consider ``////`` and ``/***`` as NatSpec comments.
|
||||
* Type Checker: Fix internal error related to ``using for`` applied to non-libraries.
|
||||
* Type Checker: Do not disallow assigning to calldata variables.
|
||||
* Type Checker: Disallow constructor parameters with ``calldata`` data location.
|
||||
* Wasm backend: Fix code generation for for-loops with pre statements.
|
||||
* Yul: Fix source location of variable multi-assignment.
|
||||
|
||||
|
@ -588,6 +588,15 @@ bool VariableDeclaration::isInternalCallableParameter() const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VariableDeclaration::isConstructorParameter() const
|
||||
{
|
||||
if (!isCallableOrCatchParameter())
|
||||
return false;
|
||||
if (auto const* function = dynamic_cast<FunctionDefinition const*>(scope()))
|
||||
return function->isConstructor();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VariableDeclaration::isLibraryFunctionParameter() const
|
||||
{
|
||||
if (!isCallableOrCatchParameter())
|
||||
@ -622,7 +631,7 @@ set<VariableDeclaration::Location> VariableDeclaration::allowedDataLocations() c
|
||||
set<Location> locations{ Location::Memory };
|
||||
if (isInternalCallableParameter() || isLibraryFunctionParameter() || isTryCatchParameter())
|
||||
locations.insert(Location::Storage);
|
||||
if (!isTryCatchParameter())
|
||||
if (!isTryCatchParameter() && !isConstructorParameter())
|
||||
locations.insert(Location::CallData);
|
||||
|
||||
return locations;
|
||||
|
@ -928,6 +928,7 @@ public:
|
||||
/// @returns true if this variable is a parameter or return parameter of an internal function
|
||||
/// or a function type of internal visibility.
|
||||
bool isInternalCallableParameter() const;
|
||||
bool isConstructorParameter() const;
|
||||
/// @returns true iff this variable is a parameter(or return parameter of a library function
|
||||
bool isLibraryFunctionParameter() const;
|
||||
/// @returns true if the type of the variable does not need to be specified, i.e. it is declared
|
||||
|
@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
constructor(uint[] calldata) public {}
|
||||
}
|
||||
// ----
|
||||
// TypeError 6651: (29-44): Data location must be "memory" for parameter in function, but "calldata" was given.
|
Loading…
Reference in New Issue
Block a user