From 60f8d2be600a4f5e398a2419b1d515c7a308f9ff Mon Sep 17 00:00:00 2001 From: Adam Pippin Date: Mon, 15 Feb 2021 11:55:01 -0800 Subject: [PATCH] Also look at variables referenced in expressions when determining dependencies between variables --- app/Engine/Cfnpp/Compiler.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Engine/Cfnpp/Compiler.php b/app/Engine/Cfnpp/Compiler.php index dfc4e9a..9c1307b 100644 --- a/app/Engine/Cfnpp/Compiler.php +++ b/app/Engine/Cfnpp/Compiler.php @@ -235,12 +235,18 @@ class Compiler implements \App\Engine\ICompile $stack = array_merge($stack, $node->getChildren()); } - // We're really only handling one case here right now if ($node instanceof NodeFunctionValue && $node->getName() == 'var') { $variables[] = $node->getValue(); } + elseif ($node instanceof NodeFunctionValue && + $node->getName() == 'expr') + { + $parser = new \App\Engine\Cfnpp\Expression\Parser(); + $expression = $parser->parse($node->getValue()); + $variables = array_merge($variables, $expression->getReferencedVariables()); + } } return $variables;