Fixed issue with multi-layer variable stacks.

This commit is contained in:
2017-05-30 18:09:33 +02:00
parent 7aad8380d1
commit 664a57ec68
3 changed files with 23 additions and 4 deletions

View File

@@ -29,7 +29,7 @@ void VariableStack::pop()
std::experimental::optional<ast::VariableDeclaration *> VariableStack::findUserVariableDeclaration(const char *variableName) const
{
const auto variableNameMatches =
const auto variableDeclarationMatches =
[&variableName](const auto &variableDeclaration)
{
return variableDeclaration->type == VariableDeclaration::Type::UserDefined
@@ -39,7 +39,7 @@ std::experimental::optional<ast::VariableDeclaration *> VariableStack::findUserV
for (auto i = m_layers.rbegin(); i != m_layers.rend(); i++)
{
auto &layer = **i;
const auto matchingVariableDeclaration = std::find_if(layer.begin(), layer.end(), variableNameMatches);
const auto matchingVariableDeclaration = std::find_if(layer.begin(), layer.end(), variableDeclarationMatches);
if (matchingVariableDeclaration != layer.end())
return matchingVariableDeclaration->get();