Skip to content

Commit 82aecc5

Browse files
committed
chore: fix test_script stack overflow
1 parent 962c24f commit 82aecc5

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/query/ast/src/parser/script.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ use nom_rule::rule;
1717

1818
use crate::ast::*;
1919
use crate::parser::common::*;
20+
use crate::parser::error::Error;
21+
use crate::parser::error::ErrorKind;
2022
use crate::parser::expr::*;
2123
use crate::parser::input::Input;
2224
use crate::parser::statement::*;
@@ -157,6 +159,22 @@ pub fn script_stmts(i: Input) -> IResult<Vec<ScriptStatement>> {
157159
}
158160

159161
pub fn script_stmt(i: Input) -> IResult<ScriptStatement> {
162+
if let Some(token) = i.tokens.first() {
163+
let kind = token.kind;
164+
if matches!(
165+
kind,
166+
END
167+
| ELSE
168+
| ELSEIF
169+
| WHEN
170+
| UNTIL
171+
) {
172+
return Err(nom::Err::Error(Error::from_error_kind(
173+
i,
174+
ErrorKind::Other("block terminator"),
175+
)));
176+
}
177+
}
160178
let let_var_stmt = map(
161179
rule! {
162180
LET ~ #declare_var

0 commit comments

Comments
 (0)