Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser: add missing level guard in if let #332

Merged
merged 1 commit into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ group_imports = "StdExternalCrate"
imports_granularity = "Module"
newline_style = "Unix"
normalize_comments = true
overflow_delimited_expr = true
style_edition = "2024"
unstable_features = true
use_field_init_shorthand = true
style_edition = "2024"

ignore = [
"testing/tests/hello.rs",
Expand Down
1 change: 1 addition & 0 deletions rinja/.rustfmt.toml
1 change: 1 addition & 0 deletions rinja_parser/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ impl<'a> CondTest<'a> {
let mut expr = Expr::parse(i, s.level, false)?;
if let Expr::BinOp(_, _, ref mut right) = expr.inner {
if matches!(right.inner, Expr::Var("set" | "let")) {
let _level_guard = s.level.nest(i)?;
*i = right.span.as_suffix_of(start).unwrap();
let start_span = Span::from(*i);
let new_right = Self::parse_cond(i, s)?;
Expand Down
11 changes: 11 additions & 0 deletions rinja_parser/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1288,3 +1288,14 @@ fn test_generics_parsing() {
)
.unwrap();
}

#[test]
fn fuzzed_deeply_tested_if_let() {
let src = include_str!("../tests/fuzzed-deeply-tested-if-let.txt");
let syntax = Syntax::default();
let err = Ast::from_str(src, None, &syntax).unwrap_err();
assert_eq!(
err.to_string().lines().next(),
Some("your template code is too deeply nested, or the last expression is too complex"),
);
}
Loading
Loading