From 98e5923e3aa5d4606de0ddc71916993478c5f9ae Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 22 Jun 2020 18:10:18 +0200 Subject: [PATCH] Do now disallow assigning to external parameters. --- Changelog.md | 1 + libsolidity/ast/AST.cpp | 7 +------ .../syntaxTests/lvalues/external_reference_argument.sol | 1 - .../libsolidity/syntaxTests/structs/memory_to_calldata.sol | 2 -- 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/Changelog.md b/Changelog.md index 843d47ba5..91a7fc43f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -11,6 +11,7 @@ Compiler Features: 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. * Yul: Fix source location of variable multi-assignment. diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 3492bfc45..f3f79f451 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -492,12 +492,7 @@ DeclarationAnnotation& Declaration::annotation() const bool VariableDeclaration::isLValue() const { // Constant declared variables are Read-Only - if (isConstant()) - return false; - // External function arguments of reference type are Read-Only - if (isExternalCallableParameter() && dynamic_cast(type())) - return false; - return true; + return !isConstant(); } bool VariableDeclaration::isLocalVariable() const diff --git a/test/libsolidity/syntaxTests/lvalues/external_reference_argument.sol b/test/libsolidity/syntaxTests/lvalues/external_reference_argument.sol index ed638781c..67378653b 100644 --- a/test/libsolidity/syntaxTests/lvalues/external_reference_argument.sol +++ b/test/libsolidity/syntaxTests/lvalues/external_reference_argument.sol @@ -4,4 +4,3 @@ contract C { } } // ---- -// TypeError 7128: (96-97): External function arguments of reference type are read-only. diff --git a/test/libsolidity/syntaxTests/structs/memory_to_calldata.sol b/test/libsolidity/syntaxTests/structs/memory_to_calldata.sol index d6b2aed6a..19747e9a5 100644 --- a/test/libsolidity/syntaxTests/structs/memory_to_calldata.sol +++ b/test/libsolidity/syntaxTests/structs/memory_to_calldata.sol @@ -5,7 +5,5 @@ contract Test { function g(S calldata s) external { S memory m; s = m; } } // ---- -// TypeError 7128: (114-115): External function arguments of reference type are read-only. // TypeError 7407: (118-122): Type struct Test.S memory is not implicitly convertible to expected type struct Test.S calldata. -// TypeError 7128: (178-179): External function arguments of reference type are read-only. // TypeError 7407: (182-183): Type struct Test.S memory is not implicitly convertible to expected type struct Test.S calldata.