mirror of
https://github.com/Noratrieb/dilaria.git
synced 2026-01-14 17:35:03 +01:00
fix stackoverflow
This commit is contained in:
parent
141e8e09bf
commit
8952e8082a
4 changed files with 201 additions and 37 deletions
|
|
@ -42,6 +42,7 @@ fn empty_block() -> Block {
|
|||
fn parser(tokens: Vec<Token>) -> Parser {
|
||||
Parser {
|
||||
tokens: tokens.into_iter().peekable(),
|
||||
depth: 0,
|
||||
inside_fn_depth: 0,
|
||||
inside_loop_depth: 0,
|
||||
}
|
||||
|
|
@ -444,6 +445,16 @@ mod expr {
|
|||
parser.expression().unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stack_overflow() {
|
||||
let tokens = std::iter::repeat(BracketO)
|
||||
.map(token)
|
||||
.take(100_000)
|
||||
.collect();
|
||||
let expr = parser(tokens).expression();
|
||||
assert!(expr.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn number_literal() {
|
||||
test_number_literal(parse_expr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue