Skip to content

Fix arrow functions in the parent expression of extends and embed tags - #5049

Merged
fabpot merged 1 commit into
twigphp:3.xfrom
nicolas-grekas:arrow-function-in-parent
Nov 24, 2026
Merged

fabpot merged 1 commit into
twigphp:3.xfrom
nicolas-grekas:arrow-function-in-parent

Conversation

@nicolas-grekas

Copy link
Copy Markdown
Contributor

Arrow functions compile to closures that use $macros, but doGetParent() didn't define it. Because of this, {% extends ["base"]|map(x => x)|first %} triggered an "Undefined variable $macros" warning, and the same happened with embed.

Defining $macros also fixes macro calls in the parent expression of extends. They failed with an error saying that the macros imported in the body are not available.

… tags

Arrow functions compile to closures that use `$macros`, but `doGetParent()` didn't define it, which triggered an "Undefined variable $macros" warning. Defining it there also makes macro calls work in the parent expression of an `extends` tag.
@fabpot
fabpot force-pushed the arrow-function-in-parent branch from 0b62ac1 to 6aca6da Compare November 24, 2026 12:46
@fabpot

fabpot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Thank you @nicolas-grekas.

@fabpot
fabpot merged commit 05455cd into twigphp:3.x Nov 24, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants