Stop looking up a macro twice in its own namespace when it is declared by a parent

This commit is contained in:
Fabien Potencier
2026-09-25 07:34:36 +02:00
parent c8d782ea0b
commit e3f0d6fb4c
+1 -1
View File
@@ -57,7 +57,7 @@ final class MacroNamespace
return $macro->callLegacy($arguments, $source, $line);
}
if (null === $macro = $this->resolve($name, $context)) {
if (null === $macro = $this->getParent($context)?->resolve($name, $context)) {
if (!str_starts_with($name, 'macro_') || null === $macro = $this->resolve($bareName = substr($name, \strlen('macro_')), $context)) {
throw new RuntimeError(\sprintf('Macro "%s" is not defined in template "%s".', $name, $this->template->getTemplateName()), $line, $source);
}