Restricting variable stack look-up to user-defined variables.
This commit is contained in:
@@ -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:
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user