Fix combinatorial explosion on backtracking broken if chains
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
b0620a00d5
commit
3f549690c1
3 changed files with 9 additions and 3 deletions
|
|
@ -346,7 +346,7 @@ fn parse_conditional_chain<'input>(
|
|||
chain.push(if_block);
|
||||
|
||||
let content = resume_after_cut(
|
||||
inner_conditional_chain,
|
||||
cut_err(inner_conditional_chain),
|
||||
repeat_till(0.., any, parse_end).map(|((), _)| ()),
|
||||
)
|
||||
.parse_next(input)?;
|
||||
|
|
@ -387,7 +387,7 @@ fn inner_conditional_chain<'input>(
|
|||
};
|
||||
|
||||
if !is_end && needs_end {
|
||||
return Err(AstError::from_input(input).cut());
|
||||
return Err(AstError::from_input(input));
|
||||
}
|
||||
|
||||
if let TemplateAstExpr::Block { expression, .. } = &end_block
|
||||
|
|
|
|||
BIN
tests/checks/long.nomo
Normal file
BIN
tests/checks/long.nomo
Normal file
Binary file not shown.
|
|
@ -31,7 +31,13 @@ fn check_cases() {
|
|||
|
||||
insta::assert_debug_snapshot!("1-parsed", parsed);
|
||||
|
||||
let ast = nomo::ast::parse(parsed.tokens()).unwrap();
|
||||
let ast = match nomo::ast::parse(parsed.tokens()) {
|
||||
Ok(ast) => ast,
|
||||
Err(err) => {
|
||||
eprintln!("{}", err.to_report(input));
|
||||
panic!("Could not evaluate ast");
|
||||
}
|
||||
};
|
||||
|
||||
insta::assert_debug_snapshot!("2-ast", ast);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue