mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9319 from ethereum/noCalldataForConstructor
Constructors cannot have calldata parameters.
This commit is contained in:
commit
9009335b3f
@ -19,6 +19,7 @@ Bugfixes:
|
|||||||
* NatSpec: Do not consider ``////`` and ``/***`` as NatSpec comments.
|
* NatSpec: Do not consider ``////`` and ``/***`` as NatSpec comments.
|
||||||
* Type Checker: Fix internal error related to ``using for`` applied to non-libraries.
|
* Type Checker: Fix internal error related to ``using for`` applied to non-libraries.
|
||||||
* Type Checker: Do not disallow assigning to calldata variables.
|
* 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.
|
* Wasm backend: Fix code generation for for-loops with pre statements.
|
||||||
* Wasm backend: Properly support both ``i32.drop`` and ``i64.drop``, and remove ``drop``.
|
* Wasm backend: Properly support both ``i32.drop`` and ``i64.drop``, and remove ``drop``.
|
||||||
* Yul: Fix source location of variable multi-assignment.
|
* Yul: Fix source location of variable multi-assignment.
|
||||||
|
@ -588,6 +588,15 @@ bool VariableDeclaration::isInternalCallableParameter() const
|
|||||||
return false;
|
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
|
bool VariableDeclaration::isLibraryFunctionParameter() const
|
||||||
{
|
{
|
||||||
if (!isCallableOrCatchParameter())
|
if (!isCallableOrCatchParameter())
|
||||||
@ -622,7 +631,7 @@ set<VariableDeclaration::Location> VariableDeclaration::allowedDataLocations() c
|
|||||||
set<Location> locations{ Location::Memory };
|
set<Location> locations{ Location::Memory };
|
||||||
if (isInternalCallableParameter() || isLibraryFunctionParameter() || isTryCatchParameter())
|
if (isInternalCallableParameter() || isLibraryFunctionParameter() || isTryCatchParameter())
|
||||||
locations.insert(Location::Storage);
|
locations.insert(Location::Storage);
|
||||||
if (!isTryCatchParameter())
|
if (!isTryCatchParameter() && !isConstructorParameter())
|
||||||
locations.insert(Location::CallData);
|
locations.insert(Location::CallData);
|
||||||
|
|
||||||
return locations;
|
return locations;
|
||||||
|
@ -928,6 +928,7 @@ public:
|
|||||||
/// @returns true if this variable is a parameter or return parameter of an internal function
|
/// @returns true if this variable is a parameter or return parameter of an internal function
|
||||||
/// or a function type of internal visibility.
|
/// or a function type of internal visibility.
|
||||||
bool isInternalCallableParameter() const;
|
bool isInternalCallableParameter() const;
|
||||||
|
bool isConstructorParameter() const;
|
||||||
/// @returns true iff this variable is a parameter(or return parameter of a library function
|
/// @returns true iff this variable is a parameter(or return parameter of a library function
|
||||||
bool isLibraryFunctionParameter() const;
|
bool isLibraryFunctionParameter() const;
|
||||||
/// @returns true if the type of the variable does not need to be specified, i.e. it is declared
|
/// @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