diff --git a/include/anthem/ASTUtils.h b/include/anthem/ASTUtils.h index 550415d..d9d0af6 100644 --- a/include/anthem/ASTUtils.h +++ b/include/anthem/ASTUtils.h @@ -26,7 +26,7 @@ class VariableStack void push(Layer layer); void pop(); - std::experimental::optional findVariableDeclaration(const char *variableName) const; + std::experimental::optional findUserVariableDeclaration(const char *variableName) const; bool contains(const ast::VariableDeclaration &variableDeclaration) const; private: diff --git a/include/anthem/Term.h b/include/anthem/Term.h index c220cf3..f92e245 100644 --- a/include/anthem/Term.h +++ b/include/anthem/Term.h @@ -85,7 +85,7 @@ struct TermTranslateVisitor std::experimental::optional visit(const Clingo::AST::Variable &variable, const Clingo::AST::Term &, Context &, RuleContext &ruleContext, const ast::VariableStack &variableStack) { - const auto matchingVariableDeclaration = variableStack.findVariableDeclaration(variable.name); + const auto matchingVariableDeclaration = variableStack.findUserVariableDeclaration(variable.name); const auto isAnonymousVariable = (strcmp(variable.name, "_") == 0); const auto isUndeclaredUserVariable = !matchingVariableDeclaration; const auto isUndeclared = isAnonymousVariable || isUndeclaredUserVariable; diff --git a/src/anthem/ASTUtils.cpp b/src/anthem/ASTUtils.cpp index f7b84a3..61cb799 100644 --- a/src/anthem/ASTUtils.cpp +++ b/src/anthem/ASTUtils.cpp @@ -27,12 +27,13 @@ void VariableStack::pop() //////////////////////////////////////////////////////////////////////////////////////////////////// -std::experimental::optional VariableStack::findVariableDeclaration(const char *variableName) const +std::experimental::optional VariableStack::findUserVariableDeclaration(const char *variableName) const { const auto variableNameMatches = [&variableName](const auto &variableDeclaration) { - return variableDeclaration->name == variableName; + return variableDeclaration->type == VariableDeclaration::Type::UserDefined + && variableDeclaration->name == variableName; }; for (auto i = m_layers.rbegin(); i != m_layers.rend(); i++)