From b7a54b01017becf7f3b90beadc71536b58e2299a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 3 Aug 2013 18:18:15 +0200 Subject: [PATCH] added an exception when a macro re-uses the same argument name twice --- lib/Twig/ExpressionParser.php | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/lib/Twig/ExpressionParser.php b/lib/Twig/ExpressionParser.php index 09d16dd..1687e11 100644 --- a/lib/Twig/ExpressionParser.php +++ b/lib/Twig/ExpressionParser.php @@ -482,7 +482,7 @@ class Twig_ExpressionParser $value = $this->parsePrimaryExpression(); if (!$this->checkConstantExpression($value)) { - throw new Twig_Error_Syntax(sprintf('A default value for an argument must be a constant (a boolean, a string, a number, or an array).'), $token->getLine(), $this->parser->getFilename()); + throw new Twig_Error_Syntax('A default value for an argument must be a constant (a boolean, a string, a number, or an array).', $token->getLine(), $this->parser->getFilename()); } } else { $value = $this->parseExpression(); @@ -497,6 +497,10 @@ class Twig_ExpressionParser if (null === $name) { $args[] = $value; } else { + if ($definition && isset($args[$name])) { + throw new Twig_Error_Syntax(sprintf('Arguments cannot contain the same argument name more than once ("%s" is defined twice).', $name), $token->getLine(), $this->parser->getFilename()); + } + $args[$name] = $value; } } -- 1.7.2.5