diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index dd926fce0e..2a88143497 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -321,12 +321,21 @@ pub fn (mut p Parser) parse_block_no_scope(is_top_level bool) []ast.Stmt { p.check(.lcbr) mut stmts := []ast.Stmt{} if p.tok.kind != .rcbr { + mut c := 0 for { stmts << p.stmt(is_top_level) // p.warn('after stmt(): tok=$p.tok.str()') if p.tok.kind in [.eof, .rcbr] { break } + c++ + if c % 100000 == 0 { + eprintln('parsed $c statements so far from fn $p.cur_fn_name ...') + } + if c > 1000000 { + p.error_with_pos('parsed over $c statements from fn $p.cur_fn_name, the parser is probably stuck', + p.tok.position()) + } } } if is_top_level {