Restricting variable stack look-up to user-defined variables.

This commit is contained in:
2017-05-30 16:39:44 +02:00
parent f78c0e4da5
commit 2964dd1309
3 changed files with 5 additions and 4 deletions

View File

@@ -26,7 +26,7 @@ class VariableStack
void push(Layer layer);
void pop();
std::experimental::optional<ast::VariableDeclaration *> findVariableDeclaration(const char *variableName) const;
std::experimental::optional<ast::VariableDeclaration *> findUserVariableDeclaration(const char *variableName) const;
bool contains(const ast::VariableDeclaration &variableDeclaration) const;
private:

View File

@@ -85,7 +85,7 @@ struct TermTranslateVisitor
std::experimental::optional<ast::Term> 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;