djc / askama

Type-safe, compiled Jinja-like templates for Rust
Apache License 2.0
3.35k stars 215 forks source link

Template compilation infinite loop / failed cycle detection #1004

Closed and-reas-se closed 4 months ago

and-reas-se commented 4 months ago

Hello,

I ran into the same bug as is reported is issue #515. That issue was closed as solved in 2021, with some cycle detection added in, but I have a simple case the cycle detection fails to trigger on.

The following project will reproduce it, running cargo build never halts.

src/lib.rs:

use askama::Template;

#[derive(Template)]
#[template(path = "page.html")]
pub struct Page;

templates/base.html:

{% extends base.html %}

templates/page.html:

{% extends base.html %}
GuillaumeGomez commented 4 months ago

Is page.html necessary to trigger it?

and-reas-se commented 4 months ago

Yes, if you do path = "base.html" in lib.rs the cycle detection triggers properly.

GuillaumeGomez commented 4 months ago

Interesting. Checking what's going on.

GuillaumeGomez commented 4 months ago

Opened https://github.com/djc/askama/pull/1005. Thanks for the detailed issue! :)