From f582d48f7bb9e5a32c7614e17ebf6b0a5ab8613a Mon Sep 17 00:00:00 2001 From: hrkrshnn Date: Mon, 31 May 2021 11:21:04 +0200 Subject: [PATCH] Error message: try-catch parameter cannot be in storage. --- libsolidity/ast/AST.cpp | 3 +-- .../tryCatch/data_location_error_message.sol | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 test/libsolidity/syntaxTests/tryCatch/data_location_error_message.sol diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 513906b81..537846007 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -696,8 +696,7 @@ set VariableDeclaration::allowedDataLocations() c if ( isConstructorParameter() || isInternalCallableParameter() || - isLibraryFunctionParameter() || - isTryCatchParameter() + isLibraryFunctionParameter() ) locations.insert(Location::Storage); if (!isTryCatchParameter() && !isConstructorParameter()) diff --git a/test/libsolidity/syntaxTests/tryCatch/data_location_error_message.sol b/test/libsolidity/syntaxTests/tryCatch/data_location_error_message.sol new file mode 100644 index 000000000..eb8e45e8a --- /dev/null +++ b/test/libsolidity/syntaxTests/tryCatch/data_location_error_message.sol @@ -0,0 +1,11 @@ +contract Foo { + function test() public { + try this.f() {} + catch Error(string reason) {} + } + + function f() public { + } +} +// ---- +// TypeError 6651: (88-101): Data location must be "memory" for parameter in function, but none was given.