From 34107b82798c5c3af9096e86fe453f3f16d3fbfb Mon Sep 17 00:00:00 2001 From: Nathan Perkins Date: Tue, 13 Jan 2015 12:30:21 -0500 Subject: [PATCH 1/2] Better variable inheritance Exhaustively search parents before reverting to scope at time of mixin. --- lessc.inc.php | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/lessc.inc.php b/lessc.inc.php index 2292f219..62b9a5c8 100644 --- a/lessc.inc.php +++ b/lessc.inc.php @@ -1835,6 +1835,9 @@ protected function set($name, $value) { protected function get($name) { $current = $this->env; + // track scope to evaluate + $scope_secondary = []; + $isArguments = $name == $this->vPrefix . 'arguments'; while ($current) { if ($isArguments && isset($current->arguments)) { @@ -1843,9 +1846,36 @@ protected function get($name) { if (isset($current->store[$name])) return $current->store[$name]; - else { - $current = isset($current->storeParent) ? - $current->storeParent : $current->parent; + + // has secondary scope? + if (isset($current->storeParent)) + $scope_secondary[] = $current->storeParent; + + if (isset($current->parent)) + $current = $current->parent; + else + $current = null; + } + + while (count($scope_secondary)) { + // pop one off + $current = array_shift($scope_secondary); + while ($current) { + if ($isArguments && isset($current->arguments)) { + return array('list', ' ', $current->arguments); + } + + if (isset($current->store[$name])) + return $current->store[$name]; + + // has secondary scope? + if (isset($current->storeParent)) + $scope_secondary[] = $current->storeParent; + + if (isset($current->parent)) + $current = $current->parent; + else + $current = null; } } From 7dd99dd07429dacae5f6a6859b01a33a1245bb35 Mon Sep 17 00:00:00 2001 From: Nathan Perkins Date: Tue, 13 Jan 2015 12:37:24 -0500 Subject: [PATCH 2/2] Fix array syntax --- lessc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lessc.inc.php b/lessc.inc.php index 62b9a5c8..7994833f 100644 --- a/lessc.inc.php +++ b/lessc.inc.php @@ -1836,7 +1836,7 @@ protected function get($name) { $current = $this->env; // track scope to evaluate - $scope_secondary = []; + $scope_secondary = array(); $isArguments = $name == $this->vPrefix . 'arguments'; while ($current) {