From 7fbd36855d643f09f591613961c367396c858e31 Mon Sep 17 00:00:00 2001 From: vlad Date: Sun, 25 Dec 2022 20:14:23 +0400 Subject: [PATCH] Disallow usage of the indexed attribute for modifier parameters Added tests for edge cases of several keywords --- Changelog.md | 1 + libsolidity/parsing/Parser.cpp | 1 - .../syntaxTests/modifiers/invalid_parameter_indexed.sol | 5 +++++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 test/libsolidity/syntaxTests/modifiers/invalid_parameter_indexed.sol diff --git a/Changelog.md b/Changelog.md index 954518dc5..2877bbf8c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -23,6 +23,7 @@ Compiler Features: Bugfixes: * Parser: Disallow several ``indexed`` attributes for the same event parameter. + * Parser: Disallow usage of the ``indexed`` attribute for modifier parameters. * Yul Optimizer: Hash hex and decimal literals according to their value instead of their representation, improving the detection of equivalent functions. * Solidity Upgrade Tool ``solidity-upgrade``: Fix the tool returning success code on uncaught exceptions. * SMTChecker: Fix display error for negative integers that are one more than powers of two. diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index e028b13ac..a9065b176 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -879,7 +879,6 @@ ASTPointer Parser::parseModifierDefinition() if (m_scanner->currentToken() == Token::LParen) { VarDeclParserOptions options; - options.allowIndexed = true; options.allowLocationSpecifier = true; parameters = parseParameterList(options); } diff --git a/test/libsolidity/syntaxTests/modifiers/invalid_parameter_indexed.sol b/test/libsolidity/syntaxTests/modifiers/invalid_parameter_indexed.sol new file mode 100644 index 000000000..a19d7beb2 --- /dev/null +++ b/test/libsolidity/syntaxTests/modifiers/invalid_parameter_indexed.sol @@ -0,0 +1,5 @@ +contract B { + modifier mod1(uint indexed a) { _; } +} +// ---- +// ParserError 2314: (36-43): Expected ',' but got 'indexed'