fix parsing of postfix expressions

This commit is contained in:
Arnaud Le Blanc
2010-11-28 21:01:23 +01:00
committed by Fabien Potencier
parent 13f80898a2
commit 7284fa9829
2 changed files with 23 additions and 2 deletions
+2 -2
View File
@@ -69,13 +69,13 @@ class Twig_ExpressionParser
$expr = $this->parseExpression($operator['precedence']);
$class = $operator['class'];
return new $class($expr, $token->getLine());
return $this->parsePostfixExpression(new $class($expr, $token->getLine()));
} elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
$this->parser->getStream()->next();
$expr = $this->parseExpression();
$this->parser->getStream()->expect(Twig_Token::PUNCTUATION_TYPE, ')');
return $expr;
return $this->parsePostfixExpression($expr);
}
return $this->parsePrimaryExpression();
@@ -0,0 +1,21 @@
--TEST--
Twig parses postfix expressions
--TEMPLATE--
{% macro foo() %}foo{% endmacro %}
{{ 'a' }}
{{ 'a'|upper }}
{{ ('a')|upper }}
{{ -1|upper }}
{{ _self.foo() }}
{{ (_self).foo() }}
--DATA--
return array();
--EXPECT--
a
A
A
-1
foo
foo