mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-02 07:20:55 +00:00

Recursive macro calls, direct and indirect, would cause a stackoverflow. This PR lets the macro call handler keep track of the stack of called macros we are currently in, so we can abort with an error message instead of panicking.
62 lines
2.3 KiB
Plaintext
62 lines
2.3 KiB
Plaintext
error: Found recursion in macro calls:
|
|
--> Direct.html:3:10
|
|
" call one %}\n "
|
|
--> Direct.html:2:25
|
|
" call one %}{% endmacro %}\n {% call one %}\n "
|
|
--> tests/ui/macro-recursion.rs:5:14
|
|
|
|
|
5 | source = "
|
|
| ______________^
|
|
6 | | {% macro one %}{% call one %}{% endmacro %}
|
|
7 | | {% call one %}
|
|
8 | | ",
|
|
| |_____^
|
|
|
|
error: Found recursion in macro calls:
|
|
--> Indirect.html:7:10
|
|
" call one %}\n "
|
|
--> Indirect.html:2:25
|
|
" call two %}{% endmacro %}\n {% macro two %}{% call three %}{% endmacro %}"...
|
|
--> Indirect.html:3:25
|
|
" call three %}{% endmacro %}\n {% macro three %}{% call four %}{% endmacro"...
|
|
--> Indirect.html:4:27
|
|
" call four %}{% endmacro %}\n {% macro four %}{% call five %}{% endmacro %"...
|
|
--> Indirect.html:5:26
|
|
" call five %}{% endmacro %}\n {% macro five %}{% call one %}{% endmacro %}"...
|
|
--> Indirect.html:6:26
|
|
" call one %}{% endmacro %}\n {% call one %}\n "
|
|
--> tests/ui/macro-recursion.rs:15:14
|
|
|
|
|
15 | source = "
|
|
| ______________^
|
|
16 | | {% macro one %}{% call two %}{% endmacro %}
|
|
17 | | {% macro two %}{% call three %}{% endmacro %}
|
|
18 | | {% macro three %}{% call four %}{% endmacro %}
|
|
... |
|
|
21 | | {% call one %}
|
|
22 | | ",
|
|
| |_____^
|
|
|
|
error: Found recursion in macro calls:
|
|
--> AcrossImports.html:6:10
|
|
" call some_macro %}\n "
|
|
--> AcrossImports.html:4:14
|
|
" call next::some_macro %}\n {% endmacro %}\n {% call some_macro %}\n "...
|
|
--> testing/templates/macro-recursion-1.html:4:6
|
|
" call next::some_macro %}\n{% endmacro %}"
|
|
--> testing/templates/macro-recursion-2.html:4:6
|
|
" call next::some_macro %}\n{% endmacro %}"
|
|
--> testing/templates/macro-recursion-3.html:4:6
|
|
" call next::some_macro %}\n{% endmacro %}"
|
|
--> tests/ui/macro-recursion.rs:29:14
|
|
|
|
|
29 | source = r#"
|
|
| ______________^
|
|
30 | | {% import "macro-recursion-1.html" as next %}
|
|
31 | | {% macro some_macro %}
|
|
32 | | {% call next::some_macro %}
|
|
33 | | {% endmacro %}
|
|
34 | | {% call some_macro %}
|
|
35 | | "#,
|
|
| |______^
|