From 2e95184d30008252909b47d784a2c269bfaf656c Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sun, 20 Feb 2022 20:50:02 +0100 Subject: [PATCH] patterns: Allow variables to be named the same as types --- lib/libimhex/source/pattern_language/validator.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/libimhex/source/pattern_language/validator.cpp b/lib/libimhex/source/pattern_language/validator.cpp index 72310a9d3..65880a322 100644 --- a/lib/libimhex/source/pattern_language/validator.cpp +++ b/lib/libimhex/source/pattern_language/validator.cpp @@ -11,6 +11,7 @@ namespace hex::pl { bool Validator::validate(const std::vector &ast) { std::unordered_set identifiers; + std::unordered_set types; try { @@ -24,8 +25,8 @@ namespace hex::pl { this->validate({ variableDeclNode->getType() }); } else if (auto typeDeclNode = dynamic_cast(node); typeDeclNode != nullptr) { - if (!identifiers.insert(typeDeclNode->getName().data()).second) - throwValidatorError(hex::format("redefinition of identifier '{0}'", typeDeclNode->getName().data()), typeDeclNode->getLineNumber()); + if (!types.insert(typeDeclNode->getName().data()).second) + throwValidatorError(hex::format("redefinition of type '{0}'", typeDeclNode->getName().data()), typeDeclNode->getLineNumber()); this->validate({ typeDeclNode->getType() }); } else if (auto structNode = dynamic_cast(node); structNode != nullptr) {