From 99f311cc5f6e5cb4f5783ed860d8b6b1c6202b5d Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 8 Jun 2020 20:35:27 +0300 Subject: [PATCH] checker: protect against stackoverflows due to deep expr recursion --- vlib/v/checker/checker.v | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 5d7fdb2c27..bfad2331ec 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -1765,14 +1765,14 @@ pub fn (c &Checker) unwrap_generic(typ table.Type) table.Type { // TODO node must be mut pub fn (mut c Checker) expr(node ast.Expr) table.Type { - /* + c.expr_level++ defer { c.expr_level -- } - if c.expr_level > 20 { - c.warn('checker: too many expr levels', node.position()) - //panic('checker: too many expr levels') + if c.expr_level > 200 { + c.error('checker: too many expr levels: $c.expr_level ', node.position()) + return table.void_type } - */ + match mut node { ast.AnonFn { keep_fn := c.cur_fn