feat: Add support for array repeat syntax: [<element_expr>; <cnt_expr>]#626
Conversation
|
Implementation looks good to me, thanks! Can you add a GUI test for cases like |
|
Also need to check what's wrong with CI. |
c98bbf6 to
704df9a
Compare
|
Fixed CI in #627. Can you rebase on |
704df9a to
f199137
Compare
|
The fuzzer seems unhappy. Did I break something? |
|
You introduced an infinite loop apparently from what I can see. |
f199137 to
3c2d173
Compare
3c2d173 to
2949d60
Compare
|
Something like this? |
|
Much better! Although spans are not there yet. :) |
|
Ok so errors looks good, well done! Now about the regression introduced in this PR, you can reproduce it with https://github.com/askama-rs/askama/actions/runs/19646142627/artifacts/4664834571. Please also add it as a testcase to prevent future regressions. |
|
So, if I understood it correctly, the fuzzing test shows that this: use askama::Template;
#[derive(Template)]
#[template(
source = r#"*{{d~[d~[d~[d~[d~[dd~[d~[d~[d~[d~[d~[D~[d~[d~[d~[d~[d~[D~[d~[dd~[d~[d~[d~[d~[d~[D~[d~[d~[d~[d~[d~[d~["#,
ext = "txt"
)]
struct FuzzingMR626;
fn main() {}should crash the parser while compiling. But it works locally for me. I just get a proper compile error: |
2949d60 to
b533b57
Compare
|
Now that it's added as ui-test, it also succeeds in the CI 🤔 Is there something I need/can change in my implementation to fix this? |
|
I think adding a limit on recursion (like 10 levels?) is the only solution. |
|
But isn't this something that can generally produce problems? {{ test(test(test(test(test(test(test(test(test(test(test(test(test(test()))))))))))))) }}How come it only occured with this array repeat implementation now? |
|
We have a nesting protection with // Level is decreased when `_level_guard` is dropped.
let _level_guard = i.state.level.nest(i)?;Can you add this line in the new array parsing please? |
f921b10 to
1a2c2bc
Compare
|
Ahh, there was already a mechanism for this. I had no idea how to add a recursion check on this 😅 I refactored the implementation a little. Now, the backtracking scope is cut off after finding |
|
This is great, thanks! Please just add one more test like |
1a2c2bc to
633de66
Compare
[<element_expr>; <cnt_expr>]
|
Thanks a lot! |
Please take a good look at the parser stuff and make sure I didn't accidentally break normal arrays 😅
Implements: #625