diff --git a/Changelog.md b/Changelog.md index a665eb576..954518dc5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -22,6 +22,7 @@ Compiler Features: Bugfixes: + * Parser: Disallow several ``indexed`` attributes for the same event parameter. * 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 fee21e518..e028b13ac 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -785,7 +785,12 @@ ASTPointer Parser::parseVariableDeclaration( else { if (_options.allowIndexed && token == Token::Indexed) + { + if (isIndexed) + parserError(5399_error, "Indexed already specified."); + isIndexed = true; + } else if (token == Token::Constant || token == Token::Immutable) { if (mutability != VariableDeclaration::Mutability::Mutable) diff --git a/test/libsolidity/syntaxTests/events/event_several_indexed_of_one_parameter.sol b/test/libsolidity/syntaxTests/events/event_several_indexed_of_one_parameter.sol new file mode 100644 index 000000000..dd6edd825 --- /dev/null +++ b/test/libsolidity/syntaxTests/events/event_several_indexed_of_one_parameter.sol @@ -0,0 +1,9 @@ +contract c { + event e(uint indexed a, bytes3 indexed indexed s, bool indexed indexed indexed b); + event e2(uint indexed indexed a, bytes3 indexed s); +} +// ---- +// ParserError 5399: (56-63): Indexed already specified. +// ParserError 5399: (80-87): Indexed already specified. +// ParserError 5399: (88-95): Indexed already specified. +// ParserError 5399: (126-133): Indexed already specified.